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


PHP MappingException::duplicateDiscriminatorEntry方法代码示例

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


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

示例1: 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

示例2: 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\MappingException::duplicateDiscriminatorEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。