當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。