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


PHP PreUpdateEventArgs::getOldValue方法代码示例

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


在下文中一共展示了PreUpdateEventArgs::getOldValue方法的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: 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

示例3: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $post = $eventArgs->getEntity();
     if ($post instanceof Post) {
         if (null === $post->getImageName()) {
             return;
         }
         if ($eventArgs->hasChangedField('imageName') && file_exists($eventArgs->getOldValue('imageName'))) {
             unlink($eventArgs->getOldValue('imageName'));
         }
     }
 }
开发者ID:syrotchukandrew,项目名称:blog,代码行数:12,代码来源:ImageEventSubscriber.php

示例4: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $article = $eventArgs->getEntity();
     if ($article instanceof Article) {
         if (null === $article->getPathToImage()) {
             return;
         }
         if ($eventArgs->hasChangedField('imageName') && file_exists($eventArgs->getOldValue('pathToImage'))) {
             unlink($eventArgs->getOldValue('pathToImage'));
         }
     }
 }
开发者ID:KateSyrotchuk,项目名称:blog,代码行数:12,代码来源:ImageEventSubscriber.php

示例5: preUpdate

 /**
  * @ORM\PreUpdate
  */
 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     if (!$this->isEdited) {
         $this->isEdited = true;
         $this->backupTime = $eventArgs->getOldValue('time');
     }
 }
开发者ID:allaniftrue,项目名称:timr,代码行数:10,代码来源:Log.php

示例6: 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

示例7: 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

示例8: preUpdate

 /**
  * Delete old avatar image from disk if it has been changed
  *
  * @param User $user
  * @param PreUpdateEventArgs $event
  */
 public function preUpdate(User $user, PreUpdateEventArgs $event)
 {
     if ($event->hasChangedField('avatarImage')) {
         $oldAvatarImage = $event->getOldValue('avatarImage');
         if (!empty($oldAvatarImage)) {
             $this->userService->deleteAvatar($oldAvatarImage);
         }
     }
 }
开发者ID:CampaignChain,项目名称:core,代码行数:15,代码来源:UserAvatarListener.php

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例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

 /**
  * @param PreUpdateEventArgs
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     if (!$args->getEntity() instanceof ISortable) {
         return;
     }
     if (!$args->hasChangedField('position')) {
         return;
     }
     $oldPos = (int) $args->getOldValue('position');
     $newPos = max(1, (int) $args->getNewValue('position'));
     $entity = $args->getEntity();
     $rp = $this->getPropReflection($entity);
     $em = $args->getEntityManager();
     $qb = $this->createBaseQb($em, $entity);
     $this->configureUpdateQb($qb, $newPos, $oldPos);
     try {
         $res = $qb->getQuery()->getSingleScalarResult();
     } catch (NoResultException $e) {
         $res = 0;
     }
     if ($newPos > $oldPos) {
         if ($res === 0) {
             //entity was last already, keep old position
             $newPos = $oldPos;
         } else {
             $newPos = min($newPos, $this->getMaxPosition($em, $entity));
         }
     }
     $rp->setValue($entity, $newPos);
     $uow = $em->getUnitOfWork();
     $meta = $em->getClassMetadata(get_class($entity));
     $uow->recomputeSingleEntityChangeSet($meta, $entity);
     $uow->getEntityPersister(get_class($entity))->update($entity);
     $uow->setOriginalEntityProperty(spl_object_hash($entity), 'position', $newPos);
     //$uow->scheduleExtraUpdate($entity, $uow->getEntityChangeSet($entity));
 }
开发者ID:librette,项目名称:doctrine-sortable,代码行数:39,代码来源:SortableListener.php


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