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


PHP ORMException::entityMissingForeignAssignedId方法代码示例

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


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

示例1: generate

 /**
  * Returns the identifier assigned to the given entity.
  *
  * @param object $entity
  * @return mixed
  * @override
  */
 public function generate(EntityManager $em, $entity)
 {
     $class = $em->getClassMetadata(get_class($entity));
     $identifier = array();
     if ($class->isIdentifierComposite) {
         $idFields = $class->getIdentifierFieldNames();
         foreach ($idFields as $idField) {
             $value = $class->reflFields[$idField]->getValue($entity);
             if (isset($value)) {
                 if (is_object($value)) {
                     if (!$em->getUnitOfWork()->isInIdentityMap($value)) {
                         throw ORMException::entityMissingForeignAssignedId($entity, $value);
                     }
                     
                     // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced.
                     $identifier[$idField] = current($em->getUnitOfWork()->getEntityIdentifier($value));
                 } else {
                     $identifier[$idField] = $value;
                 }
             } else {
                 throw ORMException::entityMissingAssignedId($entity);
             }
         }
     } else {
         $idField = $class->identifier[0];
         $value = $class->reflFields[$idField]->getValue($entity);
         if (isset($value)) {
             if (is_object($value)) {
                 if (!$em->getUnitOfWork()->isInIdentityMap($value)) {
                     throw ORMException::entityMissingForeignAssignedId($entity, $value);
                 }
                 
                 // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced.
                 $identifier[$idField] = current($em->getUnitOfWork()->getEntityIdentifier($value));
             } else {
                 $identifier[$idField] = $value;
             }
         } else {
             throw ORMException::entityMissingAssignedId($entity);
         }
     }
     
     return $identifier;
 }
开发者ID:roverwolf,项目名称:doctrine2,代码行数:51,代码来源:AssignedGenerator.php

示例2: generate

 /**
  * Returns the identifier assigned to the given entity.
  *
  * @param EntityManager $em
  * @param object        $entity
  *
  * @return mixed
  *
  * @throws \Doctrine\ORM\ORMException
  *
  * @override
  */
 public function generate(EntityManager $em, $entity)
 {
     $class = $em->getClassMetadata(get_class($entity));
     $idFields = $class->getIdentifierFieldNames();
     $identifier = array();
     foreach ($idFields as $idField) {
         $value = $class->getFieldValue($entity, $idField);
         if (!isset($value)) {
             throw ORMException::entityMissingAssignedIdForField($entity, $idField);
         }
         if (isset($class->associationMappings[$idField])) {
             if (!$em->getUnitOfWork()->isInIdentityMap($value)) {
                 throw ORMException::entityMissingForeignAssignedId($entity, $value);
             }
             // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced.
             $value = current($em->getUnitOfWork()->getEntityIdentifier($value));
         }
         $identifier[$idField] = $value;
     }
     return $identifier;
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:33,代码来源:AssignedGenerator.php


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