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


PHP ClassMetadata::setDiscriminatorMap方法代码示例

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


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

示例1: updateDiscriminator

	/**
	 * Update the discriminator map
	 * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata
	 * @param \Doctrine\ORM\EntityManager $em
	 */
	private function updateDiscriminator(\Doctrine\ORM\Mapping\ClassMetadata $metadata, \Doctrine\ORM\EntityManager $em)
	{
    	if ($metadata->name == 'Nella\Media\FileEntity' || in_array('Nella\Media\FileEntity', $metadata->parentClasses)) {
			$metadata->setDiscriminatorMap(array_merge($metadata->discriminatorMap, $this->fileMap));
    	} elseif ($metadata->name == 'Nella\Media\ImageEntity' || in_array('Nella\Media\ImageEntity', $metadata->parentClasses)) {
			$metadata->setDiscriminatorMap(array_merge($metadata->discriminatorMap, $this->imageMap));
    	}
	}
开发者ID:norbe,项目名称:framework,代码行数:13,代码来源:Listener.php

示例2: testSetDiscriminatorMapInGlobalNamespace

 /**
  * @group DDC-115
  */
 public function testSetDiscriminatorMapInGlobalNamespace()
 {
     require_once __DIR__ . "/../../Models/Global/GlobalNamespaceModel.php";
     $cm = new ClassMetadata('DoctrineGlobal_User');
     $cm->setDiscriminatorMap(array('descr' => 'DoctrineGlobal_Article', 'foo' => 'DoctrineGlobal_User'));
     $this->assertEquals("DoctrineGlobal_Article", $cm->discriminatorMap['descr']);
     $this->assertEquals("DoctrineGlobal_User", $cm->discriminatorMap['foo']);
 }
开发者ID:andreia,项目名称:doctrine,代码行数:11,代码来源:ClassMetadataTest.php

示例3: setupProfileDiscriminator

 protected function setupProfileDiscriminator(ClassMetadata $metadata)
 {
     // Set inheritence type
     $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_JOINED);
     // Set not mapped superclass
     $metadata->isMappedSuperclass = false;
     // Set discriminator column
     $metadata->setDiscriminatorColumn(['name' => 'discr', 'type' => 'string', 'length' => 20]);
     // Set map
     $metadata->setDiscriminatorMap(['user' => $this->profile, 'admin' => $this->adminProfile]);
 }
开发者ID:symedit,项目名称:symedit,代码行数:11,代码来源:MetadataSubscriber.php

示例4: addDefaultDiscriminatorMap

 /**
  * Adds a default discriminator map if no one is given
  *
  * If an entity is of any inheritance type and does not contain a
  * discriminator map, then the map is generated automatically. This process
  * is expensive computation wise.
  *
  * The automatically generated discriminator map contains the lowercase short name of
  * each class as key.
  *
  * @param \Doctrine\ORM\Mapping\ClassMetadata $class
  *
  * @throws MappingException
  */
 private function addDefaultDiscriminatorMap(ClassMetadata $class)
 {
     $allClasses = $this->driver->getAllClassNames();
     $fqcn = $class->getName();
     $map = array($this->getShortName($class->name) => $fqcn);
     $duplicates = array();
     foreach ($allClasses as $subClassCandidate) {
         if (is_subclass_of($subClassCandidate, $fqcn)) {
             $shortName = $this->getShortName($subClassCandidate);
             if (isset($map[$shortName])) {
                 $duplicates[] = $shortName;
             }
             $map[$shortName] = $subClassCandidate;
         }
     }
     if ($duplicates) {
         throw MappingException::duplicateDiscriminatorEntry($class->name, $duplicates, $map);
     }
     $class->setDiscriminatorMap($map);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:34,代码来源:ClassMetadataFactory.php

示例5: testSetDiscriminatorMapInGlobalNamespace

 /**
  * @group DDC-115
  */
 public function testSetDiscriminatorMapInGlobalNamespace()
 {
     require_once __DIR__ . "/../../Models/Global/GlobalNamespaceModel.php";
     $cm = new ClassMetadata('DoctrineGlobal_User');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $cm->setDiscriminatorMap(array('descr' => 'DoctrineGlobal_Article', 'foo' => 'DoctrineGlobal_User'));
     $this->assertEquals("DoctrineGlobal_Article", $cm->discriminatorMap['descr']);
     $this->assertEquals("DoctrineGlobal_User", $cm->discriminatorMap['foo']);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:12,代码来源:ClassMetadataTest.php

示例6: getNodesSourcesMetadata

 /**
  * Get NodesSources class metadata.
  *
  * @return Doctrine\ORM\Mapping\ClassMetadata
  */
 public static function getNodesSourcesMetadata()
 {
     $metadata = new ClassMetadata('RZ\\Roadiz\\Core\\Entities\\NodesSources');
     try {
         /**
          *  List node types
          */
         $nodeTypes = Kernel::getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\NodeType')->findAll();
         $map = [];
         foreach ($nodeTypes as $type) {
             $map[strtolower($type->getName())] = NodeType::getGeneratedEntitiesNamespace() . '\\' . $type->getSourceEntityClassName();
         }
         $metadata->setDiscriminatorMap($map);
         return $metadata;
     } catch (\PDOException $e) {
         /*
          * Database tables don't exist yet
          * Need Install
          */
         return null;
     }
 }
开发者ID:bryanbanda,项目名称:roadiz,代码行数:27,代码来源:DataInheritanceEvent.php

示例7: processDiscriminatorValues

 /**
  * Collecting discriminator map entries from child classes for entities with inheritance not equals NONE
  *
  * @param ClassMetadata $class
  * @param EntityManager $em
  *
  * @throws MappingException
  */
 protected function processDiscriminatorValues(ClassMetadata $class, EntityManager $em)
 {
     if (!$class->isInheritanceTypeNone()) {
         if ($class->isRootEntity()) {
             $allClasses = $em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
             $FQCN = $class->getName();
             $map = $class->discriminatorMap ?: [];
             $duplicates = [];
             foreach ($allClasses as $subClassCandidate) {
                 if (is_subclass_of($subClassCandidate, $FQCN) && !in_array($subClassCandidate, $map, true)) {
                     $value = $this->getDiscriminatorValue($em->getMetadataFactory(), $subClassCandidate);
                     if (null !== $value) {
                         if (isset($map[$value])) {
                             $duplicates[] = $value;
                         }
                         $map[$value] = $subClassCandidate;
                     }
                 }
             }
             if ($duplicates) {
                 throw MappingException::duplicateDiscriminatorEntry($class->getName(), $duplicates, $map);
             }
             $class->setDiscriminatorMap($map);
             $this->collectedMaps = array_merge($this->collectedMaps, array_fill_keys(array_values($map), $map));
         } elseif (isset($this->collectedMaps[$class->name]) && $class->discriminatorMap !== $this->collectedMaps[$class->name]) {
             $class->setDiscriminatorMap($this->collectedMaps[$class->name]);
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:37,代码来源:DoctrineListener.php


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