當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。