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


PHP ClassMetadata::newInstance方法代碼示例

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


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

示例1: reverseTransform

 /**
  * @inheritdoc
  */
 public function reverseTransform($value)
 {
     if (is_null($value)) {
         return null;
     }
     if (!is_numeric($value) && $this->tags && $this->property) {
         $object = $this->metadata->newInstance();
         $this->propertyAccessor->setValue($object, $this->property, $value);
         return $object;
     }
     return $this->em->getRepository($this->class)->find($value);
 }
開發者ID:snovichkov,項目名稱:Select2Bundle,代碼行數:15,代碼來源:EntityToPropertyTransformer.php

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

示例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) {
         $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

示例4: getResult

 /**
  * @param ClassMetadata $classMetadata
  * @param array $options
  * @return bool
  * @throws \InvalidArgumentException
  */
 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     if (!isset($options['property'])) {
         throw new \InvalidArgumentException('The property option must be specified!');
     }
     if (!$this->propertyAccessor->isReadable($classMetadata->newInstance(), $options['property'])) {
         return false;
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, ['property' => $options['property'], 'annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\InvisibleProperty', 'checkSetter' => false])) {
         return false;
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, ['property' => $options['property'], 'annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\CrudProperty', 'checkSetter' => false])) {
         if (!empty($options['important'])) {
             return !empty($annotation->important);
         }
         return !empty($annotation->visible);
     }
     return true;
 }
開發者ID:mikegibson,項目名稱:sentient,代碼行數:25,代碼來源:IsPropertyVisibleQuery.php

示例5: getResult

 /**
  * {@inheritdoc}
  */
 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     if (!isset($options['property'])) {
         throw new \InvalidArgumentException('The property option was not specified.');
     }
     $instance = $classMetadata->newInstance();
     if (!$this->propertyAccessor->isWritable($instance, $options['property']) || !$this->propertyAccessor->isReadable($instance, $options['property'])) {
         return false;
     }
     if (isset($options['create'])) {
         $create = $options['create'];
         unset($options['create']);
     } else {
         $create = true;
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, array_merge($options, ['annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\LockedProperty']))) {
         if ($create ? $annotation->onCreate : $annotation->onUpdate) {
             return false;
         }
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, array_merge($options, ['annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\CrudProperty']))) {
         if ($annotation->editable === CrudProperty::EDITABLE_ALWAYS) {
             return true;
         }
         if ($annotation->editable === CrudProperty::EDITABLE_NEVER) {
             return false;
         }
         if ($annotation->editable === CrudProperty::EDITABLE_ON_CREATE) {
             return $create;
         }
         if ($annotation->editable === CrudProperty::EDITABLE_ON_UPDATE) {
             return !$create;
         }
         throw new \RuntimeException('The editable property has an invalid value.');
     }
     foreach ($this->bannedAnnotations as $annotationClass) {
         if ($this->annotationQuery->getResult($classMetadata, array_merge($options, compact('annotationClass')))) {
             return false;
         }
     }
     return true;
 }
開發者ID:mikegibson,項目名稱:sentient,代碼行數:45,代碼來源:IsPropertyEditableQuery.php

示例6: newInstance

 /**
  * @param ClassMetadata $class
  *
  * @return \Doctrine\Common\Persistence\ObjectManagerAware|object
  */
 private function newInstance($class)
 {
     $entity = $class->newInstance();
     if ($entity instanceof \Doctrine\Common\Persistence\ObjectManagerAware) {
         $entity->injectObjectManager($this->em, $class);
     }
     return $entity;
 }
開發者ID:josercl,項目名稱:forum,代碼行數:13,代碼來源:UnitOfWork.php

示例7: isTranslation

 /**
  * Checks if entity is a translation
  *
  * @param  ClassMetadata $classMetadata
  * @return boolean
  */
 private function isTranslation(ClassMetadata $classMetadata)
 {
     if ($classMetadata->getReflectionClass()->isInstantiable()) {
         return $classMetadata->newInstance() instanceof TranslationInterface;
     }
     return false;
 }
開發者ID:jewome62,項目名稱:DoctrineIntl,代碼行數:13,代碼來源:TranslatableSubscriber.php

示例8: testCanInstantiateInternalPhpClassSubclass

 /**
  * @group DDC-3120
  */
 public function testCanInstantiateInternalPhpClassSubclass()
 {
     $classMetadata = new ClassMetadata(__NAMESPACE__ . '\\MyArrayObjectEntity');
     $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->assertInstanceOf(__NAMESPACE__ . '\\MyArrayObjectEntity', $classMetadata->newInstance());
 }
開發者ID:annProg,項目名稱:yourCMDB,代碼行數:9,代碼來源:ClassMetadataTest.php

示例9: __construct

 public function __construct(MaterializedPathManager $hm, ClassMetadata $meta)
 {
     $this->hm = $hm;
     $this->classMetadata = $meta;
     $this->prototype = $meta->newInstance();
 }
開發者ID:parker4444,項目名稱:Doctrine2-Hierarchical-Structural-Behavior,代碼行數:6,代碼來源:MaterializedPathQueryFactory.php

示例10: newInstance

 /** {@inheritdoc} */
 public function newInstance()
 {
     return $this->classMetadata->newInstance();
 }
開發者ID:mike227,項目名稱:n-forms,代碼行數:5,代碼來源:BaseClassMetadata.php

示例11: __construct

 /**
  * __construct
  *
  * @param Doctrine\ORM\EntityManager $em
  * @param Doctrine\ORM\Mapping\ClassMetadata $meta
  * @return void
  */
 public function __construct(EntityManager $em, ClassMetadata $meta)
 {
     $this->em = $em;
     $this->classMetadata = $meta;
     $this->prototype = $meta->newInstance();
 }
開發者ID:parker4444,項目名稱:Doctrine2-Hierarchical-Structural-Behavior,代碼行數:13,代碼來源:AbstractManager.php

示例12: testCanInstantiateInternalPhpClassSubclass

 /**
  * @group DDC-3120
  */
 public function testCanInstantiateInternalPhpClassSubclass()
 {
     $classMetadata = new ClassMetadata(__NAMESPACE__ . '\\MyArrayObjectEntity');
     $this->assertInstanceOf(__NAMESPACE__ . '\\MyArrayObjectEntity', $classMetadata->newInstance());
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:8,代碼來源:ClassMetadataTest.php


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