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


PHP PreUpdateEventArgs::hasChangedField方法代码示例

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


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

 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof $this->orderProductClass) {
         $price = $entity->getPrice();
         if ($args->hasChangedField('quantity') || $args->hasChangedField('product')) {
             $price = $entity->getQuantity() * $entity->getProduct()->getPrice();
         }
         $entity->setPrice($price);
         $entity->setUpdatedAt(new \DateTime());
     }
 }
开发者ID:hunter686,项目名称:hitechonline,代码行数:12,代码来源:OrderProductListener.php

示例4: markAsModified

 private function markAsModified(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     $securityToken = $this->securityContext->getToken();
     if (!$entity instanceof Advertisement || null == $securityToken) {
         return;
     }
     $user = $securityToken->getUser();
     if (($args->hasChangedField('description') || $args->hasChangedField('title')) && $user instanceof Advertiser && $user->getId() == $entity->getAdvertiser()->getId()) {
         $entity->markAsModified();
         $args->getEntityManager()->getUnitOfWork()->computeChangeSet($args->getEntityManager()->getClassMetadata(get_class($entity)), $entity);
     }
 }
开发者ID:topstarsmith,项目名称:Adserver-Project,代码行数:13,代码来源:AnnouncementFlowEventListener.php

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

示例6: preUpdate

 public function preUpdate(User $user, PreUpdateEventArgs $event)
 {
     if ($event->hasChangedField('email')) {
         $token = $this->tokenGenerator->generateEmailConfirmationToken($user);
         $this->emailDispatcher->sendEmailVerifyEmail($user, $token);
     }
 }
开发者ID:dstansby,项目名称:camdram,代码行数:7,代码来源:UserListener.php

示例7: preUpdate

 /**
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     if (!$args->getEntity() instanceof User || !$args->hasChangedField('email')) {
         return;
     }
     $args->getEntity()->setGoogleId(null);
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:UserEmailChangeListener.php

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

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

示例10: preUpdate

 /**
  * sets the modification date
  */
 public function preUpdate(Domains $domain, PreUpdateEventArgs $event)
 {
     $domain->setModified(new \DateTime());
     if ($event->hasChangedField('name')) {
         $domain->setNeedsSoaUpdate(true);
     }
     return true;
 }
开发者ID:syseleven,项目名称:powerdnsbundle,代码行数:11,代码来源:DomainListener.php

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

示例12: preUpdate

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

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

示例14: preUpdate

 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof Issue) {
         if ($args->hasChangedField('assignee')) {
             $entity->addCollaborator($entity->getAssignee());
         }
     }
 }
开发者ID:DenysZakharov,项目名称:task-tracker,代码行数:9,代码来源:CollaboratorEventListener.php

示例15: preUpdate

 /** @ORM\PreUpdate */
 public function preUpdate(Company $company, PreUpdateEventArgs $event)
 {
     $entity = $event->getEntity();
     $entityManager = $event->getEntityManager();
     if ($event->hasChangedField('identification')) {
         $status = $entityManager->getRepository('MainCommonBundle:Status\\PhotographerStatus')->findOneById(1);
         //To verify
         $company->setStatus($status);
     }
 }
开发者ID:TheTypoMaster,项目名称:cheeese,代码行数:11,代码来源:CompanyListener.php


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