public static function createFromConfiguration(Configuration $configuration, ObjectKey $objectKey) { $key = $objectKey->getKey(); $instance = (new static())->setResourcePath($configuration->getClassMetadataResource($key))->setResourceType($configuration->getClassMetadataResourceType($key))->setResourceClass($objectKey->getClass()); $resourceMethod = $configuration->getClassMetadataProviderMethod($key); if (isset($resourceMethod)) { $instance->setResourceMethod($resourceMethod); } return $instance; }
public function loadMetadata(ObjectKey $objectKey, LoadingCriteriaInterface $loadingCriteria, Configuration $configuration) { $cacheKey = $objectKey->getKey(); if (!isset($this->loadedMetadata[$cacheKey])) { if ($this->cache->contains($cacheKey)) { $this->loadedMetadata[$cacheKey] = $this->cache->fetch($cacheKey); } else { $classMetadata = new ClassMetadata($objectKey->getClass()); $this->metadataLoader->loadClassMetadata($classMetadata, $loadingCriteria, $configuration); $classMetadata->compile(); $this->loadedMetadata[$cacheKey] = $classMetadata; $this->cache->save($cacheKey, $classMetadata); if ($this->eventManager) { $this->eventManager->dispatch(Events::POST_LOAD_METADATA, new ClassMetadataEvent(new ClassMetadataBuilder($classMetadata))); } } } return $this->loadedMetadata[$cacheKey]; }