1 | <?php |
||
16 | class MetadataBuilder implements MetadataBuilderInterface |
||
17 | { |
||
18 | /** |
||
19 | * Контейнер с данными для фикстуры |
||
20 | * |
||
21 | * @var DataContainer\DataContainerInterface |
||
22 | */ |
||
23 | private $dataContainer; |
||
24 | |||
25 | /** |
||
26 | * Менеджер доктрины |
||
27 | * |
||
28 | * @var ObjectManager |
||
29 | */ |
||
30 | private $objectManager; |
||
31 | |||
32 | /** |
||
33 | * @var MetadataInterface |
||
34 | */ |
||
35 | private $metadata; |
||
36 | |||
37 | /** |
||
38 | * @var MetadataInterface |
||
39 | */ |
||
40 | protected $metadataPrototype; |
||
41 | |||
42 | /** |
||
43 | * MetadataBuilder constructor. |
||
44 | * |
||
45 | * @param MetadataInterface $metadataPrototype |
||
46 | */ |
||
47 | public function __construct(MetadataInterface $metadataPrototype) |
||
51 | |||
52 | /** |
||
53 | * Подготавливает метаданные |
||
54 | * |
||
55 | * @param DataContainer\DataContainerInterface $dataContainer |
||
56 | * @param $entityClassName |
||
57 | * @param ObjectManager $objectManager |
||
58 | * |
||
59 | * @return MetadataInterface |
||
60 | * @throws \Nnx\JmsSerializerModule\DoctrineObjectEngine\Exception\RuntimeException |
||
61 | */ |
||
62 | public function buildMetadata(DataContainer\DataContainerInterface $dataContainer, $entityClassName, ObjectManager $objectManager) |
||
77 | |||
78 | /** |
||
79 | * Подготавливает метаданные для сущности |
||
80 | * |
||
81 | * @param DataContainer\EntityInterface $dataItem |
||
82 | * @param $entityClassName |
||
83 | * |
||
84 | * @throws \Nnx\JmsSerializerModule\DoctrineObjectEngine\Exception\RuntimeException |
||
85 | */ |
||
86 | protected function buildMetadataForDataContainer(DataContainer\EntityInterface $dataItem, $entityClassName) |
||
107 | |||
108 | /** |
||
109 | * Добавляет метаданные для двухсторонних ассоциаций |
||
110 | * |
||
111 | * @param DataContainer\EntityInterface $childEntity |
||
112 | * @param $childEntityClassName |
||
113 | * @param DataContainer\Association $targetAssociation |
||
114 | */ |
||
115 | protected function buildReverseAssociationMetadata(DataContainer\EntityInterface $childEntity, $childEntityClassName, DataContainer\Association $targetAssociation) |
||
131 | |||
132 | |||
133 | /** |
||
134 | * Проверка контейнера с данными |
||
135 | * |
||
136 | * @param DataContainer\EntityInterface $dataItem |
||
137 | * @param $entityClassName |
||
138 | * |
||
139 | * @return void |
||
140 | * @throws \Nnx\JmsSerializerModule\DoctrineObjectEngine\Exception\RuntimeException |
||
141 | */ |
||
142 | protected function validateDataItem(DataContainer\EntityInterface $dataItem, $entityClassName) |
||
171 | } |
||
172 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: