1 | <?php |
||
24 | final class MetadataLoadInterceptor implements EventSubscriber |
||
25 | { |
||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function getSubscribedEvents() |
||
35 | |||
36 | /** |
||
37 | * Handles \Doctrine\ORM\Events::loadClassMetadata event by modifying metadata of Go! AOP proxied classes. |
||
38 | * |
||
39 | * This method intercepts loaded metadata of Doctrine's entities which are weaved by Go! AOP, |
||
40 | * and denotes them as mapped superclass. If weaved entities uses mappings from traits |
||
41 | * (such as Timestampable, Blameable, etc... from https://github.com/Atlantic18/DoctrineExtensions), |
||
42 | * it will remove all mappings from proxied class for fields inherited from traits in order to prevent |
||
43 | * collision with concrete subclass of weaved entity. Fields from trait will be present in concrete subclass |
||
44 | * of weaved entitites. |
||
45 | * |
||
46 | * @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html#mapped-superclasses |
||
47 | * @see https://github.com/Atlantic18/DoctrineExtensions |
||
48 | */ |
||
49 | 2 | public function loadClassMetadata(LoadClassMetadataEventArgs $args): void |
|
65 | |||
66 | /** |
||
67 | * Remove fields in Go! AOP proxied class metadata that are inherited |
||
68 | * from traits. |
||
69 | */ |
||
70 | 1 | private function removeMappingsFromTraits(ClassMetadata $metadata): void |
|
95 | |||
96 | /** |
||
97 | * Get ALL traits used by one class. |
||
98 | * |
||
99 | * This method is copied from https://github.com/RunOpenCode/traitor-bundle/blob/master/src/RunOpenCode/Bundle/Traitor/Utils/ClassUtils.php |
||
100 | * |
||
101 | * @param object|string $objectOrClass Instance of class or FQCN |
||
102 | * @param bool $autoload Weather to autoload class. |
||
103 | * |
||
104 | * @throws \InvalidArgumentException |
||
105 | * @throws \RuntimeException |
||
106 | */ |
||
107 | 1 | private function getTraits($objectOrClass, $autoload = true): array |
|
143 | } |
||
144 |