当前位置: 首页>>代码示例>>PHP>>正文


PHP LoadClassMetadataEventArgs::getClassMetadata方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Event\LoadClassMetadataEventArgs::getClassMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP LoadClassMetadataEventArgs::getClassMetadata方法的具体用法?PHP LoadClassMetadataEventArgs::getClassMetadata怎么用?PHP LoadClassMetadataEventArgs::getClassMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Event\LoadClassMetadataEventArgs的用法示例。


在下文中一共展示了LoadClassMetadataEventArgs::getClassMetadata方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadClassMetadata

 /**
  * @param LoadClassMetadataEventArgs $event
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     // HOT FIX for PIM-3683, when using MongoDB with PIM some queries are executed before that the schema is created
     return;
     /** @var OroEntityManager $em */
     $em = $event->getEntityManager();
     $configProvider = $em->getExtendManager()->getConfigProvider();
     $className = $event->getClassMetadata()->getName();
     if ($configProvider->hasConfig($className)) {
         $config = $configProvider->getConfig($className);
         if ($config->is('is_extend')) {
             $cmBuilder = new ClassMetadataBuilder($event->getClassMetadata());
             if ($config->is('index')) {
                 foreach ($config->get('index') as $columnName => $enabled) {
                     $fieldConfig = $configProvider->getConfig($className, $columnName);
                     if ($enabled && !$fieldConfig->is('state', ExtendManager::STATE_NEW)) {
                         $cmBuilder->addIndex(array(ExtendConfigDumper::FIELD_PREFIX . $columnName), 'oro_idx_' . $columnName);
                     }
                 }
             }
             $this->prepareRelations($config, $cmBuilder);
         }
         $em->getMetadataFactory()->setMetadataFor($className, $event->getClassMetadata());
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:28,代码来源:DoctrineSubscriber.php

示例2: loadClassMetadata

 /**
  * Event action to add the mapping to any entity using the context interface
  *
  * @param  LoadClassMetadataEventArgs $eventArgs Doctrine event args
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     // Filter out metadata that is not using the context interface
     if (!in_array(self::CONTEXT_INTERFACE, class_implements($eventArgs->getClassMetadata()->getName()))) {
         return;
     }
     // Create a variable to the naming strategy for code clarity reasons
     $namingStrategy = $eventArgs->getEntityManager()->getConfiguration()->getNamingStrategy();
     // Create a many to many mapping between the context entity and the instance entity
     $eventArgs->getClassMetadata()->mapManyToMany(array('targetEntity' => self::INSTANCE_ENTITY, 'fieldName' => 'workflowInstances', 'cascade' => array('persist'), 'joinTable' => array('name' => strtolower($namingStrategy->classToTableName($eventArgs->getClassMetadata()->getName())) . '__tyhand_workflow_instance', 'joinColumns' => array(array('name' => $namingStrategy->joinKeyColumnName($eventArgs->getClassMetadata()->getName()), 'referencedColumnName' => $namingStrategy->referenceColumnName(), 'onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')), 'inverseJoinColumns' => array(array('name' => 'workflow_instance_id', 'referencedColumnName' => $namingStrategy->referenceColumnName(), 'onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')))));
 }
开发者ID:tyhand,项目名称:workflow-bundle,代码行数:16,代码来源:ContextRelationSubscriber.php

示例3: loadClassMetadata

 /**
  * @param LoadClassMetadataEventArgs $event
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     $className = $event->getClassMetadata()->getName();
     $classMetadata = $this->metadataFactory->getMetadataForClass($className);
     /** @var \Sergiors\Taxonomy\Configuration\Metadata\EmbeddedMetadataInterface $embeddedMetadata */
     foreach ($classMetadata->getEmbeddedClasses() as $embeddedMetadata) {
         if ($embeddedMetadata->getColumnAttribute()) {
             $event->getClassMetadata()->mapField(['fieldName' => $embeddedMetadata->getPropertyName(), 'columnName' => $embeddedMetadata->getColumnAttribute()->name, 'type' => $embeddedMetadata->getColumnAttribute()->type]);
         }
     }
 }
开发者ID:sergiors,项目名称:taxonomy,代码行数:14,代码来源:ClassMetadataListener.php

示例4: loadClassMetadata

 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     $className = $event->getClassMetadata()->getName();
     $valueObjectMetadata = $this->metadataFactory->getMetadataForClass($className);
     /* @var $valueObjectMetadata ClassMetadata */
     if (!$valueObjectMetadata->hasValueObjects()) {
         return;
     }
     foreach ($valueObjectMetadata->propertyMetadata as $valueObjectPropertyMetadata) {
         $this->addValueObjectFields($event->getClassMetadata(), $valueObjectPropertyMetadata);
     }
 }
开发者ID:kawanamiyuu,项目名称:doctrine-orm-value-object,代码行数:12,代码来源:AddValueObjectMappingEventSubscriber.php

示例5: testLoadClassMetadataWithoutParent

 public function testLoadClassMetadataWithoutParent()
 {
     $this->loadClassMetadataEvent->getClassMetadata()->willReturn($this->classMetadata->reveal());
     $this->classMetadata->getName()->willReturn(get_class($this->object->reveal()));
     $this->classMetadata->setCustomRepositoryClass('Sulu\\Bundle\\ContactBundle\\Entity\\ContactRepository')->shouldNotBeCalled();
     $this->loadClassMetadataEvent->getEntityManager()->willReturn($this->entityManager->reveal());
     $this->entityManager->getConfiguration()->willReturn($this->configuration->reveal());
     $this->configuration->getNamingStrategy()->willReturn(null);
     /** @var \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver $mappingDriver */
     $mappingDriver = $this->prophesize('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver');
     $this->configuration->getMetadataDriverImpl()->willReturn($mappingDriver->reveal());
     $mappingDriver->getAllClassNames()->willReturn([get_class($this->parentObject->reveal())]);
     $mappingDriver->loadMetadataForClass(get_class($this->parentObject->reveal()), Argument::type('Doctrine\\ORM\\Mapping\\ClassMetadata'))->shouldBeCalled();
     $this->subscriber->loadClassMetadata($this->loadClassMetadataEvent->reveal());
 }
开发者ID:ollietb,项目名称:sulu,代码行数:15,代码来源:MetadataSubscriberTest.php

示例6: loadClassMetadata

 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     /** @var ClassMetadata $metadata */
     $metadata = $eventArgs->getClassMetadata();
     $reflectionClass = $metadata->getReflectionClass();
     if (!$reflectionClass) {
         return;
     }
     // Check if parents already have the Searchable trait
     foreach ($metadata->parentClasses as $parent) {
         if ($this->classAnalyzer->hasTrait($parent, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Searchable')) {
             return;
         }
     }
     // Add oneToMany mapping to entities that have the Searchable trait
     if ($this->hasTrait($reflectionClass, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Searchable')) {
         $this->logger->debug("[SearchableListener] Entering SearchableListener for « loadClassMetadata » event: entity " . $reflectionClass->getName());
         $metadata->mapOneToMany(['targetEntity' => $reflectionClass->getShortName() . 'SearchIndex', 'fieldName' => 'searchIndexes', 'mappedBy' => 'object', 'cascade' => ['persist']]);
     }
     // Add manyToOne mapping to entities that exetend SearchIndexEntity (first parent only)
     $parentClass = $reflectionClass->getParentClass();
     if ($parentClass && $parentClass->getName() == 'Librinfo\\DoctrineBundle\\Entity\\SearchIndexEntity') {
         $this->logger->debug("[SearchableListener] Entering SearchableListener for « loadClassMetadata » event: entity " . $reflectionClass->getName());
         $metadata->mapManyToOne(['targetEntity' => str_replace('SearchIndex', '', $reflectionClass->getName()), 'fieldName' => 'object', 'inversedBy' => 'searchIndexes', 'cascade' => ['persist']]);
     }
 }
开发者ID:libre-informatique,项目名称:SymfonyLibrinfoDoctrineBundle,代码行数:26,代码来源:SearchableListener.php

示例7: loadClassMetadata

 /**
  * @param LoadClassMetadataEventArgs $args
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $this->em = $args->getEntityManager();
     $this->meta = $args->getClassMetadata();
     if (!$this->em->getConnection()->getWrappedConnection() instanceof AbstractConnection) {
         return;
     }
     if ($this->meta->customPersisterClassName === null) {
         $this->meta->setCustomPersisterClass(EntityPersister::class);
     }
     $this->markIndex();
     foreach ($this->meta->fieldMappings as $property => &$mapping) {
         $this->remapIdentifier($property, $mapping);
         $this->remapVersion($property, $mapping);
         $this->markField($property, $mapping);
     }
     foreach ($this->meta->associationMappings as $property => &$mapping) {
         $this->remapAnyToOneAssociation($property, $mapping);
         $this->remapAnyToManyAssociation($property, $mapping);
         $this->remapManyToManyAssociation($property, $mapping);
     }
     if ($cache = $this->em->getMetadataFactory()->getCacheDriver()) {
         $cache->save($this->meta->name . '$CLASSMETADATA', $this->meta, null);
     }
 }
开发者ID:mihai-stancu,项目名称:orientdb-orm,代码行数:28,代码来源:OrientDBListener.php

示例8: loadClassMetadata

 /**
  * loadClassMetadata event
  *
  * Retrieves the discriminatorMap from the BlockManagar, so we can
  * add entities to the discriminatorMap without adjusting the annotations
  * in the Block entity.
  *
  * @param LoadClassMetadataEventArgs $args
  *
  * @return void
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $metadata = $args->getClassMetadata();
     if ($metadata->name == 'Opifer\\CmsBundle\\Entity\\Block') {
         $metadata->setDiscriminatorMap($this->getDiscriminatorMap());
     }
 }
开发者ID:Opifer,项目名称:Cms,代码行数:18,代码来源:BlockDiscriminatorListener.php

示例9: loadClassMetadata

 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $classMetadata = $eventArgs->getClassMetadata();
     /**
      * Problem: when visiting subclass with Single_Table inheritance type,
      * then table name was overwritten in parent class.
      * 
      * Two solutions:
      */
     if ($classMetadata->parentClasses && $classMetadata->isInheritanceTypeSingleTable()) {
         return;
     }
     /*if (strpos($classMetadata->getTableName(), $this->prefix) === 0) {
         return;
       }*/
     $classMetadata->setTableName($this->prefix . $classMetadata->getTableName());
     foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
         if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable'])) {
             $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
             // prevent double-prefix in meny-to-many inherited associations
             if (strpos($mappedTableName, $this->prefix) !== 0) {
                 $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
             }
         }
     }
 }
开发者ID:minchal,项目名称:vero,代码行数:26,代码来源:TablePrefix.php

示例10:

 function it_skips_the_lcm_event_on_default_entity(LoadClassMetadataEventArgs $eventArgs, ClassMetadata $classMetadata)
 {
     $this->beConstructedWith(UserEntityListener::DEFAULT_ENTITY);
     $eventArgs->getClassMetadata()->willReturn($classMetadata);
     $classMetadata->getName()->shouldNotBeCalled();
     $this->loadClassMetadata($eventArgs);
 }
开发者ID:saeven,项目名称:zf3-circlical-user,代码行数:7,代码来源:UserEntityListenerSpec.php

示例11: loadClassMetadata

 /**
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getClassMetadata();
     $this->mapManyToMany($metadata, $eventArgs);
     $this->mapOneToMany($metadata);
     $this->mapManyToOne($metadata, $eventArgs);
 }
开发者ID:Onnit,项目名称:Sylius,代码行数:10,代码来源:LoadMetadataSubscriber.php

示例12: loadClassMetadata

 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $classMetadata = $eventArgs->getClassMetadata();
     // add subclasses to node
     $subclasses = array_flip($this->contentTypes);
     if ($classMetadata->name == $subclasses['node']) {
         unset($subclasses['node']);
         $classMetadata->subClasses = $subclasses;
         switch ($this->inheritanceType) {
             case 'single_table':
                 $classMetadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE);
                 break;
             case 'table_per_class':
                 $classMetadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS);
                 break;
             default:
                 $classMetadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_JOINED);
                 break;
         }
         $classMetadata->setDiscriminatorColumn(array('name' => $this->discriminatorColumn, 'type' => 'string', 'length' => 50));
     }
     // check if class is defined in config
     if (isset($this->contentTypes[$classMetadata->name])) {
         // set discriminator
         $classMetadata->discriminatorMap = array_flip($this->contentTypes);
         $classMetadata->discriminatorValue = $this->contentTypes[$classMetadata->name];
     }
 }
开发者ID:hatimeria,项目名称:ZenstruckCMSBundle,代码行数:28,代码来源:DiscriminatorListener.php

示例13: loadClassMetadata

 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $em = $args->getEntityManager();
     $meta = $args->getClassMetadata();
     $class = $meta->name;
     $rootClass = $meta->rootEntityName;
     $info = Chalk::info($class);
     $parentClasses = array_merge([$class], $meta->parentClasses);
     $repositoryClasses = [];
     foreach ($parentClasses as $parentClass) {
         $parentInfo = Chalk::info($parentClass);
         $repositoryClasses[] = $parentInfo->module->class . '\\Repository\\' . $parentInfo->local->class;
     }
     $repositoryClasses[] = 'Chalk\\Repository';
     foreach ($repositoryClasses as $repositoryClass) {
         if (class_exists($repositoryClass)) {
             $meta->setCustomRepositoryClass($repositoryClass);
             break;
         }
     }
     if ($meta->discriminatorMap) {
         $meta->discriminatorMap = [Chalk::info($rootClass)->name => $rootClass];
         $allClasses = $em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
         foreach ($allClasses as $allClass) {
             if (is_subclass_of($allClass, $rootClass)) {
                 $meta->discriminatorMap[Chalk::info($allClass)->name] = $allClass;
             }
             if (is_subclass_of($allClass, $class) && !in_array($allClass, $meta->subClasses)) {
                 $meta->subClasses[] = $allClass;
             }
         }
     }
 }
开发者ID:jacksleight,项目名称:chalk,代码行数:33,代码来源:Listener.php

示例14: loadClassMetadata

 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     /** @var ClassMetadata $metadata */
     $metadata = $eventArgs->getClassMetadata();
     // Transform Librinfo entities only
     if (strpos($metadata->getName(), "Librinfo\\") !== 0) {
         return;
     }
     $this->logger->debug("[NamingListener] Entering NamingListener for « loadClassMetadata » event");
     $namingStrategy = $eventArgs->getEntityManager()->getConfiguration()->getNamingStrategy();
     // create a FQDN for the representing table
     if ($namingStrategy->classToTableName($metadata->getName()) == $metadata->table['name']) {
         $metadata->table['name'] = $this->buildTableName($metadata->name);
     }
     // create a FQDN for the ManyToMany induced tables
     foreach ($metadata->associationMappings as $field => $mapping) {
         if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide']) {
             if ($namingStrategy->classToTableName($mapping['joinTable']['name']) == $mapping['joinTable']['name']) {
                 $rc = new \ReflectionClass($mapping['targetEntity']);
                 $fqdn = $mapping['sourceEntity'] . '__' . $rc->getShortName();
                 $metadata->associationMappings[$field]['joinTable']['name'] = $this->buildTableName($fqdn);
             }
         }
     }
     $this->logger->debug("[NamingListener] Added table naming strategy to Entity", ['class' => $metadata->getName()]);
 }
开发者ID:libre-informatique,项目名称:SymfonyLibrinfoDoctrineBundle,代码行数:26,代码来源:NamingListener.php

示例15: loadClassMetadata

 /**
  * define Emailable mapping at runtime
  *
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     /** @var ClassMetadata $metadata */
     $metadata = $eventArgs->getClassMetadata();
     $reflectionClass = $metadata->getReflectionClass();
     if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Emailable')) {
         return;
     }
     // return if current entity doesn't use Emailable trait
     // Check if parents already have the Emailable trait
     foreach ($metadata->parentClasses as $parent) {
         if ($this->classAnalyzer->hasTrait($parent, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Emailable')) {
             return;
         }
     }
     $this->logger->debug("[EmailableListener] Entering EmailableListener for « loadClassMetadata » event");
     // setting default mapping configuration for Traceable
     // email
     $metadata->mapField(['fieldName' => 'email', 'type' => 'string', 'nullable' => true]);
     // emailNpai
     $metadata->mapField(['fieldName' => 'emailNpai', 'type' => 'boolean', 'nullable' => true]);
     // emailNoNewsletter
     $metadata->mapField(['fieldName' => 'emailNoNewsletter', 'type' => 'boolean', 'nullable' => true]);
     $this->logger->debug("[EmailableListener] Added Emailable mapping metadata to Entity", ['class' => $metadata->getName()]);
 }
开发者ID:libre-informatique,项目名称:SymfonyLibrinfoDoctrineBundle,代码行数:30,代码来源:EmailableListener.php


注:本文中的Doctrine\ORM\Event\LoadClassMetadataEventArgs::getClassMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。