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


PHP ClassMetadata::getReflectionProperty方法代码示例

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


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

示例1: getGroups

 /**
  *
  * @param array         $config
  * @param ClassMetadata $meta
  * @param object        $object
  *
  * @return array
  */
 private function getGroups($meta, $config, $object)
 {
     $groups = array();
     if (isset($config['groups'])) {
         foreach ($config['groups'] as $group) {
             $groups[$group] = $meta->getReflectionProperty($group)->getValue($object);
         }
     }
     return $groups;
 }
开发者ID:anhpha,项目名称:reports,代码行数:18,代码来源:SortableListener.php

示例2: updateField

 /**
  * Updates a field
  *
  * @param object           $object
  * @param AdapterInterface $eventAdapter
  * @param ClassMetadata    $meta
  * @param string           $field
  */
 protected function updateField($object, $eventAdapter, $meta, $field)
 {
     /** @var \Doctrine\Orm\Mapping\ClassMetadata|\Doctrine\ODM\MongoDB\Mapping\ClassMetadata $meta */
     $property = $meta->getReflectionProperty($field);
     $oldValue = $property->getValue($object);
     $newValue = $this->getFieldValue($meta, $field, $eventAdapter);
     // if field value is reference, persist object
     if ($meta->hasAssociation($field) && is_object($newValue)) {
         $eventAdapter->getObjectManager()->persist($newValue);
     }
     $property->setValue($object, $newValue);
     if ($object instanceof NotifyPropertyChanged) {
         $uow = $eventAdapter->getObjectManager()->getUnitOfWork();
         $uow->propertyChanged($object, $field, $oldValue, $newValue);
     }
 }
开发者ID:esserj,项目名称:DoctrineExtensions,代码行数:24,代码来源:AbstractTrackingListener.php

示例3: updateField

 /**
  * @param object           $object
  * @param object           $uow
  * @param AdapterInterface $ea
  * @param ClassMetadata    $meta
  * @param String           $field
  * @param mixed            $value
  * @param bool             $notifyPropertyChanged
  */
 protected function updateField($object, $uow, AdapterInterface $ea, ClassMetadata $meta, $field, $value, $notifyPropertyChanged = true)
 {
     $property = $meta->getReflectionProperty($field);
     $oldValue = $property->getValue($object);
     $ucField = ucfirst($field);
     $prefixes = ['add', 'set', 'property'];
     foreach ($prefixes as $prefix) {
         $method = $prefix . $ucField;
         if (method_exists($object, $method)) {
             $object->{$method}($value);
             break;
         }
         if ($prefix === 'property') {
             $property->setValue($object, $value);
             break;
         }
     }
     if ($notifyPropertyChanged && $object instanceof NotifyPropertyChanged) {
         $uow->propertyChanged($object, $field, $oldValue, $value);
     }
 }
开发者ID:coolms,项目名称:doctrine,代码行数:30,代码来源:ManagerSubscriber.php

示例4: updateField

 /**
  * @param object           $object
  * @param object           $uow
  * @param AdapterInterface $ea
  * @param ClassMetadata    $meta
  * @param String           $field
  * @param mixed            $value
  * @param bool             $notifyPropertyChanged
  */
 protected function updateField($object, $uow, AdapterInterface $ea, ClassMetadata $meta, $field, $value, $notifyPropertyChanged = true)
 {
     $property = $meta->getReflectionProperty($field);
     $oldValue = $property->getValue($object);
     $property->setValue($object, $value);
     if ($notifyPropertyChanged && $object instanceof NotifyPropertyChanged) {
         $uow = $ea->getObjectManager()->getUnitOfWork();
         $uow->propertyChanged($object, $field, $oldValue, $value);
     }
 }
开发者ID:teohhanhui,项目名称:DoctrineExtensions,代码行数:19,代码来源:UploadableListener.php

示例5: updateField

 /**
  * Updates a field
  *
  * @param object           $object
  * @param AdapterInterface $eventAdapter
  * @param ClassMetadata    $meta
  * @param string           $field
  */
 protected function updateField($object, $eventAdapter, $meta, $field)
 {
     /** @var \Doctrine\Orm\Mapping\ClassMetadata|\Doctrine\ODM\MongoDB\Mapping\ClassMetadata $meta */
     $property = $meta->getReflectionProperty($field);
     $oldValue = $property->getValue($object);
     $newValue = $this->getFieldValue($meta, $field, $eventAdapter);
     // if field value is reference, persist object
     if ($meta->hasAssociation($field) && is_object($newValue)) {
         $uow = $eventAdapter->getObjectManager()->getUnitOfWork();
         // Check to persist only when the entity isn't already managed, persists always for MongoDB
         if (!$uow instanceof UnitOfWork || $uow->getEntityState($newValue) !== UnitOfWork::STATE_MANAGED) {
             $eventAdapter->getObjectManager()->persist($newValue);
         }
     }
     $property->setValue($object, $newValue);
     if ($object instanceof NotifyPropertyChanged) {
         $uow = $eventAdapter->getObjectManager()->getUnitOfWork();
         $uow->propertyChanged($object, $field, $oldValue, $newValue);
     }
 }
开发者ID:NielsJanssen,项目名称:DoctrineExtensions,代码行数:28,代码来源:AbstractTrackingListener.php


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