当前位置: 首页>>代码示例>>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;未经允许,请勿转载。