| Total Complexity | 5 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class ClassMetadataWithEntityFactories extends ClassMetadata |
||
| 9 | { |
||
| 10 | /** @var EntityFactoryInterface[] */ |
||
| 11 | private $entityFactories; |
||
| 12 | /** @var GenericFactoryInterface|null */ |
||
| 13 | private $genericFactory; |
||
| 14 | |||
| 15 | public function __construct( |
||
| 16 | $entityName, |
||
| 17 | NamingStrategy $namingStrategy = null, |
||
| 18 | array $entityFactories = [], |
||
| 19 | GenericFactoryInterface $genericFactory = null |
||
| 20 | ) { |
||
| 21 | parent::__construct($entityName, $namingStrategy); |
||
| 22 | $this->entityFactories = $entityFactories; |
||
| 23 | $this->genericFactory = $genericFactory; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function newInstance() |
||
| 27 | { |
||
| 28 | if (isset($this->entityFactories[$this->name])) { |
||
| 29 | return $this->entityFactories[$this->name]->getEntity(); |
||
| 30 | } |
||
| 31 | |||
| 32 | if ($this->genericFactory !== null) { |
||
| 33 | return $this->genericFactory->getEntity($this->name); |
||
| 34 | } |
||
| 35 | |||
| 36 | return parent::newInstance(); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function setFactories(array $entityFactories, GenericFactoryInterface $genericFactory = null) |
||
| 43 | } |
||
| 44 | } |
||
| 45 |