|
14 | 14 | use Doctrine\ORM\EntityManagerInterface;
|
15 | 15 | use Doctrine\ORM\Mapping\AssociationMapping;
|
16 | 16 | use Doctrine\ORM\Mapping\ClassMetadata as ORMClassMetadata;
|
| 17 | +use Doctrine\ORM\Mapping\PropertyAccessors\PropertyAccessorFactory; |
17 | 18 | use Doctrine\ORM\Mapping\ToOneOwningSideMapping;
|
18 | 19 | use Doctrine\ORM\Query;
|
19 | 20 | use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory;
|
@@ -132,10 +133,21 @@ public function processMetadataLoad($em, $meta)
|
132 | 133 | 'fetch' => ORMClassMetadata::FETCH_LAZY,
|
133 | 134 | ];
|
134 | 135 | $closureMetadata->mapManyToOne($ancestorMapping);
|
135 |
| - $closureMetadata->reflFields['ancestor'] = $cmf |
136 |
| - ->getReflectionService() |
137 |
| - ->getAccessibleProperty($closureMetadata->getName(), 'ancestor') |
138 |
| - ; |
| 136 | + |
| 137 | + if (property_exists($closureMetadata, 'propertyAccessors')) { |
| 138 | + // ORM 3.4+ |
| 139 | + /** @phpstan-ignore-next-line class.NotFound Class introduced in ORM 3.4 */ |
| 140 | + $closureMetadata->propertyAccessors['ancestor'] = PropertyAccessorFactory::createPropertyAccessor( |
| 141 | + $closureMetadata->getName(), |
| 142 | + 'ancestor' |
| 143 | + ); |
| 144 | + } else { |
| 145 | + // ORM 3.3- |
| 146 | + $closureMetadata->reflFields['ancestor'] = $cmf |
| 147 | + ->getReflectionService() |
| 148 | + ->getAccessibleProperty($closureMetadata->getName(), 'ancestor') |
| 149 | + ; |
| 150 | + } |
139 | 151 | }
|
140 | 152 |
|
141 | 153 | if (!$closureMetadata->hasAssociation('descendant')) {
|
@@ -170,10 +182,21 @@ public function processMetadataLoad($em, $meta)
|
170 | 182 | 'fetch' => ORMClassMetadata::FETCH_LAZY,
|
171 | 183 | ];
|
172 | 184 | $closureMetadata->mapManyToOne($descendantMapping);
|
173 |
| - $closureMetadata->reflFields['descendant'] = $cmf |
174 |
| - ->getReflectionService() |
175 |
| - ->getAccessibleProperty($closureMetadata->getName(), 'descendant') |
176 |
| - ; |
| 185 | + |
| 186 | + if (property_exists($closureMetadata, 'propertyAccessors')) { |
| 187 | + // ORM 3.4+ |
| 188 | + /** @phpstan-ignore-next-line class.NotFound Class introduced in ORM 3.4 */ |
| 189 | + $closureMetadata->propertyAccessors['descendant'] = PropertyAccessorFactory::createPropertyAccessor( |
| 190 | + $closureMetadata->getName(), |
| 191 | + 'descendant' |
| 192 | + ); |
| 193 | + } else { |
| 194 | + // ORM 3.3- |
| 195 | + $closureMetadata->reflFields['descendant'] = $cmf |
| 196 | + ->getReflectionService() |
| 197 | + ->getAccessibleProperty($closureMetadata->getName(), 'descendant') |
| 198 | + ; |
| 199 | + } |
177 | 200 | }
|
178 | 201 |
|
179 | 202 | if (!$this->hasClosureTableUniqueConstraint($closureMetadata)) {
|
|
0 commit comments