當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassMetadata::newInstance方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::newInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMetadata::newInstance方法的具體用法?PHP ClassMetadata::newInstance怎麽用?PHP ClassMetadata::newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Persistence\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::newInstance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * Insert one new record using the Entity class.
  */
 public function execute($manager, $insertedEntities)
 {
     $obj = $this->class->newInstance();
     foreach ($this->columnFormatters as $field => $format) {
         if (null !== $format) {
             $value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
             $this->class->reflFields[$field]->setValue($obj, $value);
         }
     }
     $manager->persist($obj);
     return $obj;
 }
開發者ID:nottavi,項目名稱:Faker,代碼行數:15,代碼來源:EntityPopulator.php

示例2: reverseTransform

 /**
  * @inheritdoc
  */
 public function reverseTransform($value)
 {
     if (!is_array($value) || count($value) === 0) {
         return new ArrayCollection();
     }
     if ($this->tags && $this->property) {
         $objects = [];
         foreach ($value as $val) {
             if (!is_numeric($value)) {
                 $objects[] = $this->metadata->newInstance();
                 $this->propertyAccessor->setValue(end($objects), $this->property, $val);
             }
             $objects[] = $this->em->getRepository($this->class)->find($val);
         }
         return $objects;
     }
     return $this->em->getRepository($this->class)->findBy([$this->metadata->getIdentifier()[0] => $value]);
 }
開發者ID:snovichkov,項目名稱:Select2Bundle,代碼行數:21,代碼來源:EntitiesToPropertyTransformer.php

示例3: execute

 /**
  * Insert one new record using the Entity class.
  * @param ObjectManager $manager
  * @param bool $generateId
  * @return EntityPopulator
  */
 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:brainrepo,項目名稱:Faker,代碼行數:21,代碼來源:EntityPopulator.php


注:本文中的Doctrine\Common\Persistence\Mapping\ClassMetadata::newInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。