Example #1
0
 /**
  * @param LoadClassMetadataEventArgs $event
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     $classMetadata = $event->getClassMetadata();
     if (($resource = $this->resolveResource($classMetadata->getName())) !== null) {
         $classMetadata->isMappedSuperclass = false;
         $classMetadata->setCustomRepositoryClass($resource->getRepository());
     }
 }
 function it_load_class_metadata(LoadClassMetadataEventArgs $args, ClassMetadata $classMetadata)
 {
     $args->getClassMetadata()->willReturn($classMetadata);
     $mappings = ['item' => ['targetEntity' => 'Akeneo\\Model\\ItemInterface', 'fieldName' => 'item']];
     $classMetadata->fieldMappings = $mappings;
     $this->addResolveTargetEntity('Akeneo\\Model\\ItemInterface', 'Akeneo\\Model\\Item', []);
     $this->loadClassMetadata($args);
 }
 public function loadClassMetadata(\Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs $eventArgs)
 {
     $classMetadata = $eventArgs->getClassMetadata();
     $className = $classMetadata->getName();
     $staticProperties = $classMetadata->getReflectionClass()->getStaticProperties();
     if (array_key_exists('_TSPEC', $staticProperties) && $staticProperties['_TSPEC'] === null) {
         new $className();
     }
 }
 /**
  * Process event and resolve new target document names.
  *
  * @param LoadClassMetadataEventArgs $args
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $cm = $args->getClassMetadata();
     foreach ($cm->fieldMappings as $mapping) {
         if (isset($mapping['targetEntity']) && isset($this->targetEntities[$mapping['targetEntity']])) {
             $this->remapField($cm, $mapping);
         }
     }
 }
 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $metadata = $args->getClassMetadata();
     if ($this->urlClass !== $metadata->name) {
         return;
     }
     $metadata->db = $this->database;
     $metadata->collection = $this->collection;
 }
 /**
  * Process event and resolve new target document names.
  *
  * @param LoadClassMetadataEventArgs $args
  * @return void
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $cm = $args->getClassMetadata();
     foreach ($cm->associationMappings as $mapping) {
         if (isset($this->resolveTargetDocuments[$mapping['targetDocument']])) {
             $this->remapAssociation($cm, $mapping);
         }
     }
 }
 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getClassMetadata();
     $this->convertToDocumentIfNeeded($metadata);
     if (!$metadata->isMappedSuperclass) {
         $this->setAssociationMappings($metadata, $eventArgs->getDocumentManager()->getConfiguration());
     } else {
         $this->unsetAssociationMappings($metadata);
     }
 }
 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     /** @var ClassMetadata $metadata */
     $metadata = $eventArgs->getClassMetadata();
     $this->setCustomRepositoryClasses($metadata);
     if (!$metadata->isMappedSuperclass) {
         $this->setAssociationMappings($metadata, $eventArgs->getDocumentManager()->getConfiguration());
     } else {
         $this->unsetAssociationMappings($metadata);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     $map = [];
     $metadata = $event->getClassMetadata();
     foreach ($metadata->discriminatorMap as $discriminatorName => $discriminatorClass) {
         if (isset($this->resolveTargetEntities[$discriminatorClass])) {
             $map[$discriminatorName] = $this->resolveTargetEntities[$discriminatorClass]['targetDocument'];
         }
     }
     $metadata->setDiscriminatorMap($map);
     parent::loadClassMetadata($event);
 }
 /**
  * Add mapping to translatable entities
  *
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $classMetadata = $eventArgs->getClassMetadata();
     $reflection = $classMetadata->reflClass;
     if (!$reflection || $reflection->isAbstract()) {
         return;
     }
     if ($reflection->implementsInterface('Sylius\\Component\\Translation\\Model\\TranslatableInterface')) {
         $this->mapTranslatable($classMetadata);
     }
     if ($reflection->implementsInterface('Sylius\\Component\\Translation\\Model\\TranslationInterface')) {
         $this->mapTranslation($classMetadata);
     }
 }
Example #11
0
 /**
  * Add mapping to translatable entities.
  *
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $classMetadata = $eventArgs->getClassMetadata();
     $reflClass = $classMetadata->reflClass;
     if (!$reflClass || $reflClass->isAbstract()) {
         return;
     }
     $cubicheClassMetadata = $this->getMetadataFactory($eventArgs->getDocumentManager(), $eventArgs->getDocumentManager()->getEventManager())->getMetadataForClass($classMetadata->getName());
     foreach ($classMetadata->fieldMappings as $fieldName => &$mapping) {
         if (isset($cubicheClassMetadata->propertyMetadata[$fieldName])) {
             /** @var PropertyMetadata $propertyMetadata */
             $propertyMetadata = $cubicheClassMetadata->propertyMetadata[$fieldName];
             $mapping['cubiche:' . $propertyMetadata->namespace] = $propertyMetadata->toArray();
         }
     }
 }
 /**
  *
  * @param \Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getClassMetadata();
     $documentManager = $eventArgs->getDocumentManager();
     $eventManager = $documentManager->getEventManager();
     if (!isset($this->annotationReader)) {
         $this->annotationReader = new AnnotationReader();
         $this->annotationReader = new CachedReader($this->annotationReader, $documentManager->getConfiguration()->getMetadataCacheImpl());
     }
     //Inherit document annotations from parent classes
     $parentMetadata = [];
     if (count($metadata->parentClasses) > 0) {
         foreach ($metadata->parentClasses as $parentClass) {
             $parentMetadata[] = $documentManager->getClassMetadata($parentClass);
         }
     }
     $eventManager->dispatchEvent(CoreEvents::LOAD_METADATA, new LoadMetadataEventArgs($metadata, $parentMetadata, $this->annotationReader, $eventManager));
 }
Example #13
0
 /**
  * @param LoadClassMetadataEventArgs $event
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     /** @var ClassMetadata $classMetadata */
     $classMetadata = $event->getClassMetadata();
     if (($resource = $this->resolveResource($classMetadata->getName())) !== null) {
         foreach ($classMetadata->parentClasses as $parentClass) {
             try {
                 $parentMetadata = $event->getObjectManager()->getClassMetadata($parentClass);
             } catch (MappingException $e) {
                 continue;
             }
             /** @var ClassMetadata $parentMetadata */
             if ($parentMetadata->inheritanceType === ClassMetadata::INHERITANCE_TYPE_NONE) {
                 $parentMetadata->isMappedSuperclass = true;
             }
         }
         $classMetadata->setCustomRepositoryClass($resource->getRepository());
     }
 }
 /**
  *
  * @param \Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getClassMetadata();
     $documentManager = $eventArgs->getDocumentManager();
     $eventManager = $documentManager->getEventManager();
     if (!isset($this->annotationReader)) {
         $this->annotationReader = new Annotations\AnnotationReader();
         $this->annotationReader = new Annotations\CachedReader($this->annotationReader, $documentManager->getConfiguration()->getMetadataCacheImpl());
     }
     //Inherit document annotations from parent classes
     if (count($metadata->parentClasses) > 0) {
         foreach ($metadata->parentClasses as $parentClass) {
             $this->buildMetadata($documentManager->getClassMetadata($parentClass), $metadata, $eventManager);
         }
     }
     $this->buildMetadata($metadata, $metadata, $eventManager);
     // Raise post build metadata event
     if ($eventManager->hasListeners(Events::postBuildMetadata)) {
         $eventManager->dispatchEvent(Events::postBuildMetadata, $eventArgs);
     }
 }
 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $this->setCustomRepositoryClass($eventArgs->getClassMetadata());
 }
Example #16
0
 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function postLoadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $this->checkCoordinateType($eventArgs->getClassMetadata());
 }
 function let(RegistryInterface $registry, LoadClassMetadataEventArgs $event, ClassMetadata $classMetadata)
 {
     $classMetadata->getName()->willReturn('Foo');
     $event->getClassMetadata()->willReturn($classMetadata);
     $this->beConstructedWith($registry);
 }
Example #18
0
 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function postLoadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $this->checkValueObjectType($eventArgs->getClassMetadata());
 }
Example #19
0
 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function postLoadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $this->checkEnumType($eventArgs->getClassMetadata());
     $this->checkTypes($eventArgs->getClassMetadata());
 }
 public function loadClassMetadata(\Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs $eventArgs)
 {
     $classMetadata = $eventArgs->getClassMetadata();
     $field = array('fieldName' => 'about', 'type' => 'string');
     $classMetadata->mapField($field);
 }
 public function postBuildMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getClassMetadata();
     if (!isset($metadata->generator)) {
         return;
     }
     //Add implied generatable inputs
     if (array_key_exists(Generator\Form::getResourceName($metadata->name), $metadata->generator)) {
         foreach ($this->getSerializer()->fieldListForUnserialize($metadata) as $field) {
             if (!array_key_exists(Generator\Input::getResourceName($metadata->name, $field), $metadata->generator)) {
                 $this->annotationDojoInput(new AnnotationEventArgs($metadata, EventType::field, new Sds\Dojo\Input([]), $metadata->reflFields[$field], $eventArgs->getDocumentManager()->getEventManager()));
             }
         }
     }
     //Add implied generatable validators
     foreach ($this->getSerializer()->fieldListForUnserialize($metadata) as $field) {
         if (array_key_exists(Generator\Input::getResourceName($metadata->name, $field), $metadata->generator) && array_key_exists($field, $metadata->validator['fields']) && !array_key_exists(Generator\Validator::getResourceName($metadata->name, $field), $metadata->generator)) {
             $this->annotationDojoValidator(new AnnotationEventArgs($metadata, EventType::field, new Sds\Dojo\Validator([]), $metadata->reflFields[$field], $eventArgs->getDocumentManager()->getEventManager()));
         }
     }
     //Add implied multifieldvalidator
     if ((array_key_exists(Generator\Form::getResourceName($metadata->name), $metadata->generator) || array_key_exists(Generator\ModelValidator::getResourceName($metadata->name), $metadata->generator)) && array_key_exists('document', $metadata->validator) && !array_key_exists(Generator\MultiFieldValidator::getResourceName($metadata->name), $metadata->generator)) {
         $this->annotationDojoMultiFieldValidator(new AnnotationEventArgs($metadata, EventType::document, new Sds\Dojo\MultiFieldValidator([]), $metadata->reflClass, $eventArgs->getDocumentManager()->getEventManager()));
     }
 }
Example #22
0
 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function postLoadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $this->checkArrayCollectionType($eventArgs->getClassMetadata());
 }