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


PHP PreUpdateEventArgs::getNewValue方法代码示例

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


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

示例1: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $order = $eventArgs->getEntity();
     if (!$order instanceof \Shopware\Models\Order\Order) {
         return;
     }
     //order or payment status changed?
     if ($eventArgs->hasChangedField('paymentStatus') || $eventArgs->hasChangedField('orderStatus')) {
         $historyData = array('userID' => null, 'change_date' => date('Y-m-d H:i:s'), 'orderID' => $order->getId());
         if (Shopware()->Auth()->getIdentity() && Shopware()->Auth()->getIdentity()->id) {
             $user = $eventArgs->getEntityManager()->find('Shopware\\Models\\User\\User', Shopware()->Auth()->getIdentity()->id);
             $historyData['userID'] = $user->getId();
         }
         //order status changed?
         if ($eventArgs->hasChangedField('orderStatus')) {
             $historyData['previous_order_status_id'] = $eventArgs->getOldValue('orderStatus')->getId();
             $historyData['order_status_id'] = $eventArgs->getNewValue('orderStatus')->getId();
         } else {
             $historyData['previous_order_status_id'] = $order->getOrderStatus()->getId();
             $historyData['order_status_id'] = $order->getOrderStatus()->getId();
         }
         //payment status changed?
         if ($eventArgs->hasChangedField('paymentStatus')) {
             $historyData['previous_payment_status_id'] = $eventArgs->getOldValue('paymentStatus')->getId();
             $historyData['payment_status_id'] = $eventArgs->getNewValue('paymentStatus')->getId();
         } else {
             $historyData['previous_payment_status_id'] = $order->getPaymentStatus()->getId();
             $historyData['payment_status_id'] = $order->getPaymentStatus()->getId();
         }
         $eventArgs->getEntityManager()->getConnection()->insert('s_order_history', $historyData);
     }
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:32,代码来源:OrderHistorySubscriber.php

示例2: preUpdate

 /**
  * @param PreUpdateEventArgs $event
  */
 public function preUpdate(PreUpdateEventArgs $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof CalendarEvent) {
         if ($event->hasChangedField('start') || $event->hasChangedField('reminder')) {
             $needChangeSetsComputing = false;
             if ($event->hasChangedField('reminder')) {
                 if ($event->getNewValue('reminder')) {
                     $start = $event->hasChangedField('start') ? $event->getNewValue('start') : $entity->getStart();
                     $entity->setRemindAt($this->remindTimeCalculator->calculateRemindAt($start));
                 } else {
                     $entity->setRemindAt(null);
                 }
                 if ($entity->getReminded()) {
                     $entity->setReminded(false);
                 }
                 $needChangeSetsComputing = true;
             } else {
                 if ($entity->getReminder()) {
                     $entity->setRemindAt($this->remindTimeCalculator->calculateRemindAt($event->getNewValue('start')));
                     $needChangeSetsComputing = true;
                 }
                 if ($entity->getReminded()) {
                     $entity->setReminded(false);
                     $needChangeSetsComputing = true;
                 }
             }
             if ($needChangeSetsComputing) {
                 $em = $event->getEntityManager();
                 $uow = $em->getUnitOfWork();
                 $uow->recomputeSingleEntityChangeSet($em->getClassMetadata('OroCalendarBundle:CalendarEvent'), $entity);
             }
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:38,代码来源:EntitySubscriber.php

示例3: getChangesets

 private function getChangesets(PreUpdateEventArgs $args)
 {
     $oldValues = array();
     $newValues = array();
     $fields = array('avatar' => 'Фото', 'firstName' => 'Имя', 'lastName' => 'Фамилия', 'surName' => 'Отчество', 'birthdate' => 'Дата рождения', 'hideBirthdate' => 'Скрывать дату рождения', 'city' => 'Город', 'address' => 'Адрес', 'university' => 'ВУЗ', 'graduateYear' => 'Год окончания ВУЗа', 'primarySpecialty' => 'Основная специальность', 'secondarySpecialty' => 'Второстепенная специальность', 'specialization' => 'Специализация', 'academicTitle' => 'Звание', 'jobType' => 'Место работы', 'job' => 'Название организации', 'jobAlignment' => 'Место организации', 'phone' => 'Телефон', 'position' => 'Должность', 'diploma' => 'Диплом ВУЗа', 'achievements' => 'О себе', 'academicDegree' => 'Ученая степень', 'dissertation' => 'Тема диссертации', 'diplomaScientic' => 'Диплом ученой степени', 'digestSubscribed' => 'Подписка на дайджест', 'commentSubscribed' => 'Подписка ответов на комментарии');
     foreach ($fields as $field => $label) {
         if ($args->hasChangedField($field)) {
             $old = $args->getOldValue($field);
             $new = $args->getNewValue($field);
             if ($old == $new || is_array($old) && empty($new)) {
                 continue;
             }
             if ($new instanceof UploadedFile) {
                 $this->imgFields[$field] = $label;
                 $oldValues[] = "<b>{$label}:</b> ~";
             } else {
                 $oldValues[] = "<b>{$label}:</b> " . ($old instanceof \DateTime ? $old->format('d.m.Y') : $old);
                 $newValues[] = "<b>{$label}:</b> " . ($new instanceof \DateTime ? $new->format('d.m.Y') : $new);
             }
         }
     }
     if (count($oldValues)) {
         $oldValues = implode('<br/>', $oldValues);
         $newValues = implode('<br/>', $newValues);
         return array($oldValues, $newValues);
     }
     return array(null, null);
 }
开发者ID:Quiss,项目名称:Evrika,代码行数:28,代码来源:ChangesSubscriber.php

示例4: preUpdate

 /**
  * @ORM\PreUpdate
  */
 public function preUpdate($item, PreUpdateEventArgs $event)
 {
     if ($item->getLevel() > 0) {
         $item->setRootSequence(NULL);
     } elseif ($event->hasChangedField('parent') && is_null($event->getNewValue('parent')) && !is_null($event->getOldValue('parent'))) {
         $this->setMaxRootSequence($item, $event);
     } else {
         if (!$event->hasChangedField('rootSequence')) {
             return;
         }
         $oldSequence = $event->getOldValue('rootSequence');
         $newSequence = $event->getNewValue('rootSequence');
         if ($oldSequence === $newSequence) {
             return;
         }
         $em = $event->getEntityManager();
         $qb = $em->createQueryBuilder();
         $qb->update(get_class($item), 'i')->where('i.rootSequence = ' . $newSequence);
         if ($newSequence > $oldSequence) {
             $qb->set('i.rootSequence', 'i.rootSequence - 1');
         } elseif ($newSequence < $oldSequence) {
             $qb->set('i.rootSequence', 'i.rootSequence + 1');
         }
         $qb->getQuery()->execute();
     }
 }
开发者ID:jirinapravnik,项目名称:common,代码行数:29,代码来源:RootSequenceListener.php

示例5: preUpdate

 public function preUpdate(\Doctrine\ORM\Event\PreUpdateEventArgs $eventArgs)
 {
     if ($eventArgs->getEntity() instanceof User) {
         /**
          * SET DATE_SORTIE ON NULL IF USER IS REACTIVATE AFTER DESACTIVATION (because date_sortie < now)
          */
         if ($eventArgs->hasChangedField('enabled') && $eventArgs->getNewValue('enabled') == true && $eventArgs->getEntity()->getDateSortie() < new \DateTime('now')) {
             $eventArgs->getEntity()->setDateSortie(null);
             $eventArgs->getEntity()->setRaisonSortie(null);
         }
         /**
          * Change in profile => pointeur field to 1 (back to 0 by the admin in the BDD directly)
          */
         if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField('phone') || $eventArgs->hasChangedField('adresse') || $eventArgs->hasChangedField('ville') || $eventArgs->hasChangedField('zip') || $eventArgs->hasChangedField('photo_id') || $eventArgs->hasChangedField('service_id') || $eventArgs->hasChangedField('enabled') || $eventArgs->hasChangedField('password') || $eventArgs->hasChangedField('date_of_birth') || $eventArgs->hasChangedField('firstname') || $eventArgs->hasChangedField('lastname') || $eventArgs->hasChangedField('date_entree') || $eventArgs->hasChangedField('date_sortie') || $eventArgs->hasChangedField('raison_sortie') || $eventArgs->hasChangedField('username')) {
             $eventArgs->getEntity()->setPointeur(true);
         }
         /**
          * SEND MAIL ON PROFILE CHANGES
          */
         if ($this->container->getParameter('mail.edit_profil.enabled') == true) {
             if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField('phone') || $eventArgs->hasChangedField('adresse') || $eventArgs->hasChangedField('ville') || $eventArgs->hasChangedField('zip')) {
                 if ($this->container->hasParameter('mail.edit_profil')) {
                     $mail = $this->container->getParameter('mail.edit_profil');
                 } else {
                     $this->container->setParameter('mail.edit_profil.enabled', false);
                 }
                 $message = \Swift_Message::newInstance()->setSubject('Changements dans le profil de ' . $eventArgs->getEntity())->setFrom('sacha@ch-laloupe.fr')->setTo($mail)->setBody($this->getMailBody($eventArgs->getEntityChangeSet(), $eventArgs->getEntity()), 'text/html');
                 $this->mailer->send($message);
             }
         }
     }
 }
开发者ID:WildCodeSchool,项目名称:projet-intranet_hopital,代码行数:32,代码来源:editProfileListener.php

示例6: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     if ($eventArgs->getEntity() instanceof Badge) {
         if ($eventArgs->hasChangedField('remis') && $eventArgs->getNewValue('remis') == false) {
             $date = new \DateTime('now');
             $eventArgs->getEntity()->setDateRendu($date);
         }
     }
 }
开发者ID:luciemannechez,项目名称:projet-intranet_hopital,代码行数:9,代码来源:BadgeListener.php

示例7: hasChanged

 private function hasChanged(PreUpdateEventArgs $event)
 {
     $hasChanged = FALSE;
     foreach ($this->propertyInfos as $property => $value) {
         if ($event->hasChangedField($property) && !empty($event->getOldValue($property)) && \trim($event->getOldValue($property)) !== \trim($event->getNewValue($property))) {
             $hasChanged = TRUE;
         }
     }
     return $hasChanged;
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:10,代码来源:EditProfileListener.php

示例8: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     if ($eventArgs->getEntity() instanceof Role && $eventArgs->hasChangedField('role')) {
         $oldRoleName = $eventArgs->getOldValue('role');
         $newRoleName = $eventArgs->getNewValue('role');
         /** @var $aclSidManager AclSidManager */
         $aclSidManager = $this->aclSidManagerLink->getService();
         $aclSidManager->updateSid($aclSidManager->getSid($newRoleName), $oldRoleName);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:10,代码来源:RoleListener.php

示例9: 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 
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $reflectionClass = new ReflectionClass($args->getEntity());
     $properties = $reflectionClass->getProperties();
     foreach ($properties as $refProperty) {
         $propName = $refProperty->getName();
         if ($this->annReader->getPropertyAnnotation($refProperty, self::ENCRYPTED_ANN_NAME) && $args->hasChangedField($propName)) {
             $args->setNewValue($propName, $this->encryptor->encrypt($args->getNewValue($propName)));
         }
     }
 }
开发者ID:gzseee,项目名称:DoctrineEncryptBundle,代码行数:17,代码来源:DoctrineEncryptSubscriber.php

示例10: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     if ($eventArgs->getEntity() instanceof Registration) {
         if ($eventArgs->hasChangedField('status') && $eventArgs->getNewValue('status') == 'paid') {
             $registration = $eventArgs->getEntity();
             $user = $registration->getUser();
             $systemMailer = $this->container->get('system_mailer');
             $systemMailer->send('App:paid_registration', ['user' => $user, 'registration' => $registration], 'es');
         }
     }
 }
开发者ID:aulasoftwarelibre,项目名称:ritsiga,代码行数:11,代码来源:NotificationListener.php

示例11: preUpdate

 /**
  * Maj des scripts du serveur si la config du serveur (port, maxplayers, dir) a été modifié
  * Ou si la config du jeu (bin, binDir, launchName, map, orangebox, source) a été modifié
  * Ou si l'IP publique de la machine a été modifié
  * 
  * Réinstallation du serveur
  * Si des modifs ont été faites sur la machine (IP privée, home, user)
  * Ou si le serveur de jeu n'est plus sur la meme machine
  * Ou si le jeu du serveur est modifié
  * 
  * @param \Doctrine\ORM\Event\PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof SteamServer) {
         if ($args->hasChangedField('port') || $args->hasChangedField('maxplayers') && $entity->getGame()->getLaunchName() != "csgo" || $args->hasChangedField('core') || $args->hasChangedField('mode')) {
             try {
                 $entity->uploadHldsScript($this->getTwig());
             } catch (\Exception $e) {
             }
         }
         if ($args->hasChangedField('maxplayers') && $entity->getGame()->getLaunchName() == "csgo") {
             try {
                 $entity->modifyGameModesCfg();
             } catch (\Exception $e) {
             }
         }
         if ($args->hasChangedField('dir')) {
             try {
                 $entity->uploadShellScripts($this->getTwig());
             } catch (\Exception $e) {
             }
         }
         if ($args->hasChangedField('rebootAt')) {
             //suppression del'ancienne tâche cron
             $entity->removeAutoReboot($args->getOldValue('rebootAt'));
             if ($args->getNewValue('rebootAt') != null) {
                 $entity->addAutoReboot();
             }
         }
         if ($args->hasChangedField('name') || $args->hasChangedField('rconPassword')) {
             try {
                 $entity->modifyServerCfgFile();
             } catch (\Exception $e) {
             }
         }
     } elseif ($entity instanceof Machine) {
         // Upload des scripts si l'IP publique ou le home de la machine a été modifié
         if ($args->hasChangedField('publicIp') || $args->hasChangedField('home')) {
             $servers = $entity->getGameServers();
             foreach ($servers as $server) {
                 if (!$server instanceof SteamServer) {
                     continue;
                 }
                 try {
                     $server->uploadShellScripts($this->getTwig());
                 } catch (\Exception $e) {
                 }
             }
         }
     }
 }
开发者ID:Onneil,项目名称:dedipanel,代码行数:63,代码来源:ConfigModifier.php

示例12: preUpdate

 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     $entityManager = $args->getEntityManager();
     if (!$entity instanceof User) {
         return;
     }
     if ($args->hasChangedField('username')) {
         $class = ClassUtils::getRealClass($entity);
         $old_username = $args->getOldValue('username');
         $new_username = $args->getNewValue('username');
         $entityManager->getConnection()->update('acl_security_identities', array('identifier' => sprintf('%s-%s', $class, $new_username)), array('identifier' => sprintf('%s-%s', $class, $old_username)));
     }
 }
开发者ID:mapbender,项目名称:fom,代码行数:14,代码来源:UserSubscriber.php

示例13: preUpdate

 public function preUpdate(PreUpdateEventArgs $event)
 {
     $entity = $event->getEntity();
     foreach ($this->getFileReferenceFields($entity) as $field) {
         if ($event->hasChangedField($field)) {
             $newFileReference = $event->getNewValue($field);
             $oldFileReference = $event->getOldValue($field);
         } else {
             $newFileReference = $this->getFieldValue($event, $field);
             $oldFileReference = $this->getOldValues($event, $field);
         }
         $id = $this->getIdentity($entity, $field);
         $this->uploader->update($id, $newFileReference, $oldFileReference);
     }
 }
开发者ID:atom-azimov,项目名称:uploader,代码行数:15,代码来源:ORMEmbeddableListener.php

示例14: preUpdate

 /**
  * @ORM\PreUpdate
  */
 public function preUpdate($item, PreUpdateEventArgs $event)
 {
     if (!$event->hasChangedField('sequence')) {
         return;
     }
     $oldSequence = $event->getOldValue('sequence');
     $newSequence = $event->getNewValue('sequence');
     $em = $event->getEntityManager();
     //posouvam o jedno, ci-li v $newSequence je hodnota toho na ktere posouvam
     $qb = $em->createQueryBuilder();
     $qb->update(get_class($item), 'i')->where('i.sequence = ' . $newSequence);
     if ($newSequence > $oldSequence) {
         $qb->set('i.sequence', 'i.sequence - 1');
     } elseif ($newSequence < $oldSequence) {
         $qb->set('i.sequence', 'i.sequence + 1');
     }
     $qb->getQuery()->execute();
 }
开发者ID:jirinapravnik,项目名称:common,代码行数:21,代码来源:SequenceListener.php

示例15: preUpdate

 /**
  * Handle pre update event
  *
  * @param PreUpdateEventArgs $args Event arguments
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $annotations = $this->container->get('cyber_app.metadata.reader')->getUploadebleFieldsAnnotations($args->getEntity());
     if (0 === count($annotations)) {
         return;
     }
     foreach ($annotations as $field => $annotation) {
         if (!($args->hasChangedField($field) && $args->getOldValue($field))) {
             continue;
         }
         $config = $this->container->getParameter('oneup_uploader.config.' . $annotation->endpoint);
         if ($annotation->multiple) {
             $files = array_diff((array) $args->getOldValue($field), (array) $args->getNewValue($field));
             foreach ($files as $file) {
                 $this->unlink($annotation->endpoint, $config['storage'], $file);
             }
             continue;
         }
         if ($args->getOldValue($field)) {
             $this->unlink($annotation->endpoint, $config['storage'], $args->getOldValue($field));
         }
     }
 }
开发者ID:snovichkov,项目名称:UploaderBundle,代码行数:28,代码来源:RemoveListener.php


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