Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function getMetadataForType($type)
 {
     if (null !== ($metadata = $this->doLoadMetadata($type))) {
         // Found in memory or from cache implementation
         return $metadata;
     }
     // Loop through the type hierarchy (extension) and merge metadata objects.
     foreach ($this->driver->getTypeHierarchy($type) as $hierType) {
         if (null !== ($loaded = $this->doLoadMetadata($hierType))) {
             // Found in memory or from cache implementation
             $this->mergeMetadata($metadata, $loaded);
             continue;
         }
         // Load from driver source
         $loaded = $this->driver->loadMetadataForType($hierType);
         if (null === $loaded) {
             throw MetadataException::mappingNotFound($type);
         }
         // Validate the metadata object.
         $this->entityUtil->validateMetadata($hierType, $loaded, $this);
         // Handle persistence specific loading and validation.
         $persisterKey = $loaded->persistence->getKey();
         $persistenceFactory = $this->driver->getPersistenceMetadataFactory($persisterKey);
         $persistenceFactory->handleLoad($loaded);
         $persistenceFactory->handleValidate($loaded);
         // Handle search specific loading and validation.
         $clientKey = $loaded->search->getKey();
         $searchFactory = $this->driver->getSearchMetadataFactory($clientKey);
         $searchFactory->handleLoad($loaded);
         $searchFactory->handleValidate($loaded);
         $this->mergeMetadata($metadata, $loaded);
         $this->doPutMetadata($loaded);
     }
     if (null === $metadata) {
         throw MetadataException::mappingNotFound($type);
     }
     $this->doPutMetadata($metadata);
     return $metadata;
 }