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


PHP ClassMetadata::setFieldValue方法代码示例

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


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

示例1: _assignDefaultVersionValue

 /**
  * Retrieves the default version value which was created
  * by the preceding INSERT statement and assigns it back in to the 
  * entities version field.
  *
  * @param Doctrine\ORM\Mapping\ClassMetadata $class
  * @param object $entity
  * @param mixed $id
  */
 protected function _assignDefaultVersionValue($class, $entity, $id)
 {
     $versionField = $this->_class->versionField;
     $identifier = $this->_class->getIdentifierColumnNames();
     $versionFieldColumnName = $this->_class->getColumnName($versionField);
     //FIXME: Order with composite keys might not be correct
     $sql = "SELECT " . $versionFieldColumnName . " FROM " . $class->getQuotedTableName($this->_platform) . " WHERE " . implode(' = ? AND ', $identifier) . " = ?";
     $value = $this->_conn->fetchColumn($sql, array_values((array) $id));
     $this->_class->setFieldValue($entity, $versionField, $value);
 }
开发者ID:jeffreiffers,项目名称:doctrine2,代码行数:19,代码来源:BasicEntityPersister.php

示例2: getCollectionFromAssociation

 /**
  * @param string $association
  * @return Collection
  * @throws UnexpectedValueException
  */
 protected function getCollectionFromAssociation($association)
 {
     $collection = $this->metadata->getFieldValue($this->entity, $association);
     if ($collection === NULL) {
         $this->metadata->setFieldValue($this->entity, $association, $collection = new ArrayCollection());
     } elseif (!$collection instanceof Collection) {
         throw UnexpectedValueException::notACollection($this->entity, $association);
     }
     return $collection;
 }
开发者ID:librette,项目名称:doctrine,代码行数:15,代码来源:WrappedEntity.php

示例3: clearProperties

 /**
  * @param ClassMetadata $metadata
  * @param object|array  $entity
  * @param array         $properties
  */
 protected function clearProperties(ClassMetadata $metadata, &$entity, array $properties)
 {
     if (is_array($entity)) {
         foreach ($properties as $property) {
             $entity[$property] = null;
         }
     } else {
         foreach ($properties as $property) {
             if ($metadata->hasField($property) || $metadata->hasAssociation($property)) {
                 $metadata->setFieldValue($entity, $property, null);
             }
         }
     }
 }
开发者ID:vend,项目名称:doxport,代码行数:19,代码来源:QueryAction.php

示例4: getCollection

 /**
  * @param $object
  * @param $fieldName
  * @return ArrayCollection|mixed
  * @throws \NForms\Exceptions\MetadataException
  */
 protected function getCollection($object, $fieldName)
 {
     if ($this->isSingleValuedAssociation($fieldName)) {
         throw new MetadataException("Can't get collection from association toOne.");
     }
     $collection = $this->classMetadata->getFieldValue($object, $fieldName);
     if ($collection === NULL) {
         $collection = new ArrayCollection();
         $this->classMetadata->setFieldValue($object, $fieldName, $collection);
     }
     if (!$collection instanceof Collection) {
         throw new MetadataException('Expected Doctrine\\Common\\Collections\\Collection, given ' . (is_object($collection) ? get_class($collection) : gettype($collection)));
     }
     return $collection;
 }
开发者ID:mike227,项目名称:n-forms,代码行数:21,代码来源:BaseClassMetadata.php

示例5: getRelation

 /**
  * @param ClassMetadata $meta
  * @param object $entity
  * @param string $field
  * @return bool|object
  */
 private function getRelation(ClassMetadata $meta, $entity, $field)
 {
     if (!$meta->hasAssociation($field) || !$meta->isSingleValuedAssociation($field)) {
         return FALSE;
     }
     // todo: allow access using property or method
     $relation = $meta->getFieldValue($entity, $field);
     if ($relation instanceof Collection) {
         return FALSE;
     }
     if ($relation === NULL) {
         $class = $meta->getAssociationTargetClass($field);
         $relationMeta = $this->mapper->getEntityManager()->getClassMetadata($class);
         $relation = $relationMeta->newInstance();
         $meta->setFieldValue($entity, $field, $relation);
     }
     return $relation;
 }
开发者ID:kuba1999,项目名称:DoctrineForms,代码行数:24,代码来源:ToOne.php

示例6: assignDefaultVersionValue

 /**
  * Retrieves the default version value which was created
  * by the preceding INSERT statement and assigns it back in to the
  * entities version field.
  *
  * @param object $entity
  * @param mixed $id
  */
 protected function assignDefaultVersionValue($entity, $id)
 {
     $value = $this->fetchVersionValue($this->_class, $id);
     $this->_class->setFieldValue($entity, $this->_class->versionField, $value);
 }
开发者ID:jfkz,项目名称:aquarel-cms,代码行数:13,代码来源:BasicEntityPersister.php

示例7: setProperty

 /**
  * Set entity property value according to meta.
  *
  * @param ClassMetadata $meta
  * @param Entity        $entity
  * @param string        $name
  * @param string        $value
  *
  * @return Entity
  */
 private function setProperty(ClassMetadata $meta, Entity &$entity, $name, $value)
 {
     if ($meta->hasField($name) && !$meta->isIdentifier($name)) {
         $meta->setFieldValue($entity, $name, $value);
     } elseif ($meta->hasAssociation($name)) {
         // We have a single value and there is only one column in association
         if (!is_array($value) && !is_object($value) && $meta->isAssociationWithSingleJoinColumn($name)) {
             $id = [$meta->associationMappings[$name]['joinColumns'][0]['referencedColumnName'] => $value];
             $di = Di::getInstance();
             $linkedEntity = $di->em->find($meta->getAssociationTargetClass($name), $id);
             if (is_null($linkedEntity)) {
                 throw new ClientException('Entity not found for nested entity ' . json_encode(['name' => $name]), ClientException::CODE_NOT_FOUND);
             } else {
                 $meta->setFieldValue($entity, $name, $linkedEntity);
             }
         } else {
             throw new ServerException('Unhandled association type for field ' . $name . ' on ' . $meta->name, ServerException::CODE_NOT_IMPLEMENTED);
         }
     }
 }
开发者ID:petitchevalroux,项目名称:newswatcher-api,代码行数:30,代码来源:JsonApiController.php

示例8: save

 /**
  * {@inheritdoc}
  */
 public function save(ClassMetadata $meta, Component $component, $entity)
 {
     if (!$component instanceof BaseControl) {
         return FALSE;
     }
     if ($meta->hasField($name = $component->getOption(self::FIELD_NAME, $component->getName()))) {
         if (!$component->getOption(self::FIELD_NOT_SAVE, false)) {
             $this->accessor->setValue($entity, $name, $component->getValue());
         }
         return TRUE;
     }
     if (!$meta->hasAssociation($name)) {
         return FALSE;
     }
     if (!($identifier = $component->getValue())) {
         return FALSE;
     }
     $repository = $this->em->getRepository($this->relatedMetadata($entity, $name)->getName());
     if ($relation = $repository->find($identifier)) {
         $meta->setFieldValue($entity, $name, $relation);
     }
     return TRUE;
 }
开发者ID:kuba1999,项目名称:DoctrineForms,代码行数:26,代码来源:TextControl.php

示例9: getCollection

 /**
  * @param ClassMetadata $meta
  * @param object $entity
  * @param string $field
  * @return Collection
  */
 private function getCollection(ClassMetadata $meta, $entity, $field)
 {
     if (!$meta->hasAssociation($field) || $meta->isSingleValuedAssociation($field)) {
         return FALSE;
     }
     $collection = $meta->getFieldValue($entity, $field);
     if ($collection === NULL) {
         $collection = new ArrayCollection();
         $meta->setFieldValue($entity, $field, $collection);
     }
     return $collection;
 }
开发者ID:kuba1999,项目名称:DoctrineForms,代码行数:18,代码来源:ToMany.php


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