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


PHP ClassMetadata::getIdentifier方法代码示例

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


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

示例1: transform

 /**
  * @inheritdoc
  */
 public function transform($value)
 {
     if (null === $value) {
         return [];
     }
     $text = is_null($this->property) ? (string) $value : $this->propertyAccessor->getValue($value, $this->property);
     $identifier = $this->propertyAccessor->getValue($value, $this->metadata->getIdentifier()[0]);
     return [$identifier ?: $text => $text];
 }
开发者ID:snovichkov,项目名称:Select2Bundle,代码行数:12,代码来源:EntityToPropertyTransformer.php

示例2: refresh

 /**
  * @param object $entity
  * @return object
  */
 public function refresh($entity)
 {
     $column = $this->metaData->getIdentifier()[0];
     $queryResult = $this->em->createQueryBuilder()->select('*')->from($this->metaData->getTableName())->where($column . ' = :id')->setParameter('id', $entity->{$column})->execute()->fetch();
     if (!$queryResult) {
         throw new RuntimeException('Cannot refresh entity with ' . $column . ' = ' . $entity->{$column});
     }
     return $this->hydrate($entity, $queryResult);
 }
开发者ID:lynx,项目名称:lynx,代码行数:13,代码来源:Repository.php

示例3: execute

 /**
  * Insert one new record using the Entity class.
  */
 public function execute(ObjectManager $manager, $insertedEntities, $generateId = false)
 {
     $obj = $this->class->newInstance();
     $this->fillColumns($obj, $insertedEntities);
     $this->callMethods($obj, $insertedEntities);
     if ($generateId) {
         $idsName = $this->class->getIdentifier();
         foreach ($idsName as $idName) {
             $id = $this->generateId($obj, $idName, $manager);
             $this->class->reflFields[$idName]->setValue($obj, $id);
         }
     }
     $manager->persist($obj);
     return $obj;
 }
开发者ID:edom-huang,项目名称:myweb,代码行数:18,代码来源:EntityPopulator.php

示例4: execute

 /**
  * Insert one new record using the Entity class.
  */
 public function execute(ObjectManager $manager, $insertedEntities, $generateId = false)
 {
     $obj = $this->class->newInstance();
     $this->fillColumns($obj, $insertedEntities);
     $this->callMethods($obj, $insertedEntities);
     if ($generateId) {
         $ids = $this->class->getIdentifier();
         for ($i = 0; $i < count($ids); $i++) {
             // foreach ($idsName as $idName) {
             $generateId = $this->generateId($obj, $ids[$i], $manager);
             $this->class->reflFields[$ids[$i]]->setValue($obj, $generateId);
         }
     }
     //echo "Wykonuję persist";
     $manager->persist($obj);
     $manager->flush($obj);
     return $obj;
 }
开发者ID:TMSolution,项目名称:GeneratorBundle,代码行数:21,代码来源:EntityPopulator.php

示例5: getIdentifier

 /**
  * @param ClassMetadata $metadata
  *
  * @return string
  * @throws LogicException
  */
 protected function getIdentifier(ClassMetadata $metadata)
 {
     if ($metadata->isIdentifierComposite) {
         throw new \LogicException('Composite identifiers are not supported.');
     }
     return $metadata->getIdentifier()[0];
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:ActivityListFilter.php


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