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


PHP LifecycleEventArgs::getEntityChangeSet方法代码示例

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


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

示例1: preUpdate

 /**
  * Sets origin and destination coordinates before updating.
  *
  * Method will only call geocode() if one of the location fields was changed
  * by the user.
  *
  * @param LifecycleEventArgs $eventArgs
  */
 public function preUpdate(LifecycleEventArgs $eventArgs)
 {
     $object = $eventArgs->getEntity();
     if ($object instanceof RouteAwareInterface) {
         if (count(array_intersect(array_keys($eventArgs->getEntityChangeSet()), $this->originFields)) > 0) {
             $this->updateOriginCoordinates($object);
             $this->updateDistance($object);
         }
         if (count(array_intersect(array_keys($eventArgs->getEntityChangeSet()), $this->destinationFields)) > 0) {
             $this->updateDestinationCoordinates($object);
             $this->updateDistance($object);
         }
     }
 }
开发者ID:whte-rbt,项目名称:foundation-bundle,代码行数:22,代码来源:RouteSubscriber.php

示例2: preUpdate

 /**
  * Sets location coordinates before updating.
  *
  * Method will only call geocode() if one of the location fields was changed
  * by the user.
  *
  * @param LifecycleEventArgs $eventArgs
  */
 public function preUpdate(LifecycleEventArgs $eventArgs)
 {
     $object = $eventArgs->getEntity();
     if ($object instanceof LocationAwareInterface) {
         if (count(array_intersect(array_keys($eventArgs->getEntityChangeSet()), $this->locationFields)) > 0) {
             $this->updateCoordinates($object);
         }
     }
 }
开发者ID:whte-rbt,项目名称:foundation-bundle,代码行数:17,代码来源:LocationSubscriber.php

示例3: preUpdate

 public function preUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $token = $this->container->get('security.token_storage')->getToken();
     //OAuth
     if (!$token) {
         return;
     }
     $translator = $this->container->get('translator');
     $annotations = $this->container->get('annotations');
     $utils = $this->container->get('utils');
     $className = $utils->getObjectClass($entity);
     $changes = $args->getEntityChangeSet();
     $meta = $annotations->getAll($className);
     $log = '';
     $idx = 1;
     foreach ($changes as $field => $change) {
         $fieldName = ucfirst(strtolower($field));
         if (isset($meta['properties']['data'][$field])) {
             $fieldName = $meta['properties']['data'][$field]->getTitle();
         }
         // было
         if ($change[0] instanceof \DateTime) {
             $was = $change[0]->format('Y-m-d H:is');
         } else {
             $was = $change[0];
         }
         // стало
         if ($change[1] instanceof \DateTime) {
             $became = $change[1]->format('Y-m-d H:is');
         } else {
             $became = $change[1];
         }
         $log .= "<strong>" . $translator->trans($fieldName, [], 'global') . "</strong><br />";
         $log .= " - " . $translator->trans('It was', [], 'global') . ": " . $was . "<br />";
         $log .= " - " . $translator->trans('It became', [], 'global') . ": " . $became . "<br />";
         if ($idx < count($changes)) {
             $log .= "<br />";
             $idx++;
         }
     }
     if ($this->skipCondition($entity)) {
         $history = new History();
         $history->setCreatedAt(new \DateTime());
         $history->setUser($token->getUser());
         $history->setEntityCode($utils->getUnderscore($className));
         $history->setType('update');
         $history->setEntryId($entity->getId());
         $history->setLog($log);
         $this->history[] = $history;
     }
 }
开发者ID:busaev,项目名称:s3,代码行数:52,代码来源:EntityLogger.php

示例4: preUpdatePayment

 /**
  * preUpdatePayment
  * 
  * @param LifecycleEventArgs $args
  */
 protected function preUpdatePayment(LifecycleEventArgs $args)
 {
     $object = $args->getEntity();
     $em = $args->getEntityManager();
     $array_changes = $args->getEntityChangeSet();
     //echo"<pre>";print_r($array_changes['paymentSystem'][0]->getName());echo"</pre>";exit;
     if (isset($array_changes['amount']) or isset($array_changes['paymentSystem']) or isset($array_changes['flag'])) {
         $uow = $em->getUnitOfWork();
         $PaymentChanged = new \Rodina\CrmBundle\Entity\Abonent\PaymentChanged($object, isset($array_changes['amount']) ? $array_changes['amount'][0] : $object->getAmount(), isset($array_changes['comment']) ? $array_changes['comment'][0] : $object->getComment(), isset($array_changes['paySystem']) ? $array_changes['paySystem'][0] : $object->getPaySystem(), isset($array_changes['payType']) ? $array_changes['payType'][0] : $object->getPayType(), isset($array_changes['payServiceComment']) ? $array_changes['payServiceComment'][0] : $object->getPayServiceComment(), isset($array_changes['receipt']) ? $array_changes['receipt'][0] : $object->getReceipt(), isset($array_changes['payDate']) ? $array_changes['payDate'][0] : $object->getPayDate(), isset($array_changes['localDate']) ? $array_changes['localDate'][0] : $object->getLocalDate(), isset($array_changes['flag']) ? $array_changes['flag'][0] : $object->getFlag(), isset($array_changes['paymentSystem']) ? $array_changes['paymentSystem'][0] : $object->getPaymentSystem(), isset($array_changes['manager']) ? $array_changes['manager'][0] : $object->getManager());
         $em->persist($PaymentChanged);
         $object->addChange($PaymentChanged);
         $uow->recomputeSingleEntityChangeSet($em->getClassMetadata("Rodina\\CrmBundle\\Entity\\Abonent\\Payment"), $object);
     }
 }
开发者ID:vape1,项目名称:example_php_symfony,代码行数:19,代码来源:ChangeUpdateListener.php


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