public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadata = $eventArgs->getClassMetadata(); $cacheKey = $this->getCacheKey($metadata->getName()); $cache = $this->getCache($eventArgs->getEntityManager()); $enums = []; foreach ($metadata->getFieldNames() as $field) { if (isset(self::$enumTypeMap[$metadata->getTypeOfField($field)])) { $reflProp = $metadata->getReflectionClass()->getProperty($field); foreach ($this->annotationReader->getPropertyAnnotations($reflProp) as $annotation) { if ($annotation instanceof Enum) { $enums[$field] = $annotation; } } } } if (count($enums)) { $cache->save($cacheKey, $enums); } }
public static function getMappings(LifecycleEventArgs $eventArguments) { $meta = $eventArguments->getEntityManager()->getClassMetadata(get_class($eventArguments->getEntity())); $class = $meta->getReflectionClass(); if (isset(self::$mappings[$class->getName()])) { return self::$mappings[$class->getName()]; } self::$mappings[$class->getName()] = []; $reader = new CachedReader(new AnnotationReader(), $eventArguments->getEntityManager()->getConfiguration()->getMetadataCacheImpl()); foreach ($class->getProperties() as $property) { $annotations = $reader->getPropertyAnnotations($property); foreach ($annotations as $annotation) { if (isset(self::$mappingNames[get_class($annotation)])) { self::$mappings[$class->getName()][get_class($annotation)][$property->getName()] = $annotation; } } } return self::$mappings[$class->getName()]; }