当前位置: 首页>>代码示例>>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;未经允许,请勿转载。