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


PHP PreUpdateEventArgs::getEntity方法代碼示例

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


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

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

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

示例5: preUpdate

 /**
  * Pre update event process
  *
  * @param LifecycleEventArgs $args
  * @return $this
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entityClass = ClassUtils::getClass($args->getEntity());
     if (array_key_exists($entityClass, $this->notificationRules)) {
         $rules = $this->notificationRules[$entityClass];
         $event = new PreUpdateNotificationEvent($args->getEntity(), $args->getEntityChangeSet(), array('em' => $args->getEntityManager(), 'rules' => $rules));
         $this->eventDispatcher->dispatch('numerique1.notification.event.entity_pre_update', $event);
     }
     return $this;
 }
開發者ID:Numerique1,項目名稱:NotificationBundle,代碼行數:16,代碼來源:NotificationDoctrineListener.php

示例6: preUpdate

 /**
  * @param PreUpdateEventArgs $eventArgs
  */
 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     if ($this->prepareMedia($entity)) {
         // Hack ? Don't know, that's the behaviour Doctrine 2 seems to want
         // See : http://www.doctrine-project.org/jira/browse/DDC-1020
         $em = $eventArgs->getEntityManager();
         $uow = $em->getUnitOfWork();
         $uow->recomputeSingleEntityChangeSet($em->getClassMetadata(ClassLookup::getClass($entity)), $eventArgs->getEntity());
     }
 }
開發者ID:bureaublauwgeel,項目名稱:KunstmaanMediaBundle,代碼行數:14,代碼來源:DoctrineMediaListener.php

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

示例8: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     if ($entity instanceof StampEntityInterface) {
         $entity->setModified(new \DateTime());
     }
 }
開發者ID:apitude,項目名稱:apitude,代碼行數:7,代碼來源:StampSubscriber.php

示例9: preUpdate

 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof ContainerAwareInterface) {
         $entity->setContainer($this->container);
     }
 }
開發者ID:slim627,項目名稱:bellon,代碼行數:7,代碼來源:ContainerListener.php

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

示例11: preUpdate

 /**
  * Before an update we check that the product categories are right.
  *
  * @param PreUpdateEventArgs $event The pre update event.
  */
 public function preUpdate(PreUpdateEventArgs $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof ProductInterface) {
         $this->categoryIntegrityFixer->fixProduct($entity);
     }
 }
開發者ID:axelvnk,項目名稱:elcodi,代碼行數:12,代碼來源:ProductCategoryIntegrityEventListener.php

示例12: preUpdate

 /**
  * Before an update we check that the product categories are right.
  *
  * @param PreUpdateEventArgs $event The pre update event.
  */
 public function preUpdate(PreUpdateEventArgs $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof CategorizableInterface) {
         $this->categoryIntegrityFixer->fixCategoriesIntegrity($entity);
     }
 }
開發者ID:EmanueleMinotto,項目名稱:elcodi,代碼行數:12,代碼來源:CategoryIntegrityEventListener.php

示例13: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     if (!$entity instanceof User) {
         return;
     }
     $this->encodePassword($entity);
 }
開發者ID:neandher,項目名稱:Symfony-Multiple-Authentication,代碼行數:8,代碼來源:EncodePasswordSubscriber.php

示例14: preUpdate

 /**
  * @param PreUpdateEventArgs $event
  */
 public function preUpdate(PreUpdateEventArgs $event)
 {
     $entity = $event->getEntity();
     // if subtotal or status has been changed
     if ($this->isOrderValid($entity) && array_intersect(['subtotalAmount', 'discountAmount', 'status'], array_keys($event->getEntityChangeSet()))) {
         $this->ordersForUpdate[$entity->getId()] = true;
     }
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:11,代碼來源:OrderListener.php

示例15: preUpdate

 public function preUpdate(PreUpdateEventArgs $event)
 {
     $file = $event->getEntity();
     if (!$file instanceof File) {
         return;
     }
     $this->updateFile($file);
 }
開發者ID:xavier-dubreuil,項目名稱:LightCMS,代碼行數:8,代碼來源:FileEventListener.php


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