1: <?php
2:
3: /*
4: * This file is part of the CRUDlex package.
5: *
6: * (c) Philip Lehmann-Böhm <philip@philiplb.de>
7: *
8: * For the full copyright and license information, please view the LICENSE
9: * file that was distributed with this source code.
10: */
11:
12: namespace CRUDlex;
13:
14: use CRUDlex\CRUDDataFactoryInterface;
15: use CRUDlex\CRUDMySQLData;
16:
17: /**
18: * A factory implementation for {@see CRUDMySQLData} instances.
19: */
20: class CRUDMySQLDataFactory implements CRUDDataFactoryInterface {
21:
22: /**
23: * Holds the Doctrine DBAL instance.
24: */
25: protected $db;
26:
27: /**
28: * Constructor.
29: *
30: * @param $db
31: * the Doctrine DBAL instance
32: */
33: public function __construct($db) {
34: $this->db = $db;
35: }
36:
37: /**
38: * {@inheritdoc}
39: */
40: public function createData(CRUDEntityDefinition $definition, CRUDFileProcessorInterface $fileProcessor) {
41: return new CRUDMySQLData($definition, $fileProcessor, $this->db);
42: }
43:
44: }
45: