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


PHP PreUpdateEventArgs::getObject方法代碼示例

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


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

示例1: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $this->object = $eventArgs->getObject();
     $class = str_replace("Proxies\\__CG__\\", "", get_class($this->object));
     if (!array_key_exists($class, $this->actions)) {
         return;
     }
     $this->logger->debug("[NormalizeListener] Entering NormalizeListener for « preUpdate » event");
     $this->normalizeFields();
 }
開發者ID:libre-informatique,項目名稱:SymfonyLibrinfoDoctrineBundle,代碼行數:10,代碼來源:NormalizeListener.php

示例2: preUpdate

 /**
  * Listen a preUpdate lifecycle event. Checking and encrypt entities fields
  * which have @Encrypted annotation. Using changesets to avoid preUpdate event
  * restrictions
  * 
  * @param LifecycleEventArgs $args 
  * 
  * @return void
  * @access public
  * @author etienne de Longeaux <etienne.delongeaux@gmail.com>
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     if ($this->_update_enabled == true) {
         $entity = $args->getEntity();
         $em = $args->getEntityManager();
         $uow = $em->getUnitOfWork();
         $reflectionClass = new ReflectionClass($args->getEntity());
         $properties = $reflectionClass->getProperties();
         $className = get_class($entity);
         foreach ($properties as $refProperty) {
             foreach ($this->options as $key => $encrypter) {
                 if (isset($encrypter['encryptor_annotation_name']) && isset($encrypter['encryptor_class']) && isset($encrypter['encryptor_options'])) {
                     $this->encryptor = $this->getEncryptorService($key);
                     if ($this->annReader->getPropertyAnnotation($refProperty, $encrypter['encryptor_annotation_name'])) {
                         // we have annotation and if it decrypt operation, we must avoid duble decryption
                         $propName = $refProperty->getName();
                         // we encrypt the field
                         if ($refProperty->isPublic()) {
                             $entity->{$propName} = $this->encryptor->encrypt($refProperty->getValue());
                         } else {
                             $methodName = \Sfynx\ToolBundle\Util\PiStringManager::capitalize($propName);
                             if ($reflectionClass->hasMethod($getter = 'get' . $methodName) && $reflectionClass->hasMethod($setter = 'set' . $methodName)) {
                                 // we get the locale value
                                 $locale = false;
                                 $om = $args->getObjectManager();
                                 $object = $args->getObject();
                                 $meta = $om->getClassMetadata(get_class($object));
                                 $config = $this->getConfiguration($om, $meta->name);
                                 if (isset($config['fields'])) {
                                     $locale = $this->getTranslatableLocale($object, $meta);
                                 }
                                 // we set the encrypt value
                                 $currentPropValue = $entity->{$getter}();
                                 if (!empty($currentPropValue)) {
                                     $currentPropValue = $this->encryptor->encrypt($currentPropValue);
                                 }
                                 // we set locale value
                                 if ($locale) {
                                     //                                        if ($locale == $this->locale) {
                                     //                                            $entity->$setter($currentPropValue);
                                     //                                        }
                                     $entity->{$setter}($currentPropValue);
                                     $entity->translate($locale)->{$setter}($currentPropValue);
                                     //$uow->persist($entity);
                                     //$uow->computeChangeSets();
                                 }
                             } else {
                                 throw new \RuntimeException(sprintf("Property %s isn't public and doesn't has getter/setter"));
                             }
                         }
                     }
                 } else {
                     throw new \RuntimeException(sprintf("encrypter is not correctly configured"));
                 }
             }
         }
     }
 }
開發者ID:pigroupe,項目名稱:SfynxEncryptBundle,代碼行數:69,代碼來源:EncryptSubscriber.php

示例3: preUpdate

 /**
  * Gets called before updates
  *
  * @param PreUpdateEventArgs $eventArgs
  */
 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $entity = $eventArgs->getObject();
     // If it's a Taggable entity, mark the entity to be saved
     if ($this->isEntitySupported($this->getReflClass($entity))) {
         $this->addEntityToSave($entity);
     }
 }
開發者ID:smart85,項目名稱:UnifikDoctrineBehaviorsBundle,代碼行數:13,代碼來源:TaggableListener.php


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