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


PHP PreUpdateEventArgs::getEntityChangeSet方法代码示例

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


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

示例1: preUpdate

 public function preUpdate(\Doctrine\ORM\Event\PreUpdateEventArgs $eventArgs)
 {
     if ($eventArgs->getEntity() instanceof User) {
         /**
          * SET DATE_SORTIE ON NULL IF USER IS REACTIVATE AFTER DESACTIVATION (because date_sortie < now)
          */
         if ($eventArgs->hasChangedField('enabled') && $eventArgs->getNewValue('enabled') == true && $eventArgs->getEntity()->getDateSortie() < new \DateTime('now')) {
             $eventArgs->getEntity()->setDateSortie(null);
             $eventArgs->getEntity()->setRaisonSortie(null);
         }
         /**
          * Change in profile => pointeur field to 1 (back to 0 by the admin in the BDD directly)
          */
         if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField('phone') || $eventArgs->hasChangedField('adresse') || $eventArgs->hasChangedField('ville') || $eventArgs->hasChangedField('zip') || $eventArgs->hasChangedField('photo_id') || $eventArgs->hasChangedField('service_id') || $eventArgs->hasChangedField('enabled') || $eventArgs->hasChangedField('password') || $eventArgs->hasChangedField('date_of_birth') || $eventArgs->hasChangedField('firstname') || $eventArgs->hasChangedField('lastname') || $eventArgs->hasChangedField('date_entree') || $eventArgs->hasChangedField('date_sortie') || $eventArgs->hasChangedField('raison_sortie') || $eventArgs->hasChangedField('username')) {
             $eventArgs->getEntity()->setPointeur(true);
         }
         /**
          * SEND MAIL ON PROFILE CHANGES
          */
         if ($this->container->getParameter('mail.edit_profil.enabled') == true) {
             if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField('phone') || $eventArgs->hasChangedField('adresse') || $eventArgs->hasChangedField('ville') || $eventArgs->hasChangedField('zip')) {
                 if ($this->container->hasParameter('mail.edit_profil')) {
                     $mail = $this->container->getParameter('mail.edit_profil');
                 } else {
                     $this->container->setParameter('mail.edit_profil.enabled', false);
                 }
                 $message = \Swift_Message::newInstance()->setSubject('Changements dans le profil de ' . $eventArgs->getEntity())->setFrom('sacha@ch-laloupe.fr')->setTo($mail)->setBody($this->getMailBody($eventArgs->getEntityChangeSet(), $eventArgs->getEntity()), 'text/html');
                 $this->mailer->send($message);
             }
         }
     }
 }
开发者ID:WildCodeSchool,项目名称:projet-intranet_hopital,代码行数:32,代码来源:editProfileListener.php

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

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

示例4: preUpdate

 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof Ticket) {
         $followers = array();
         foreach ($entity->getFollowers() as $key => $value) {
             $followers[] = $value->getEmail();
         }
         $changelog = $args->getEntityChangeSet();
         $body = $this->container->get('templating')->render('TaskeetMainBundle:Default:email.txt.twig', array('entity' => $entity, 'changelog' => $changelog));
         $message = \Swift_Message::newInstance()->setSubject("Tarea modificada")->setFrom('no-reply@personaltask.com')->setTo($followers)->setBody($body);
         $this->container->get('mailer')->send($message);
     }
 }
开发者ID:jarmas8611,项目名称:proyect,代码行数:14,代码来源:FollowersEventSubscriber.php

示例5: preUpdate

 /**
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $annotationReader = $this->getReaderFromEntityManager($args->getEntityManager());
     $entity = $args->getEntity();
     $changeSet = $args->getEntityChangeSet();
     $reflObject = new \ReflectionObject($entity);
     foreach ($changeSet as $propertyName => $values) {
         $property = $reflObject->getProperty($propertyName);
         /** @var PostUpdate $annotation */
         if ($annotation = $annotationReader->getPropertyAnnotation($property, PostUpdate::class)) {
             $className = $annotation->value;
             if (is_subclass_of($className, HandlerInterface::class)) {
                 $this->changedProperties[] = ['handlerClassName' => $className, 'entity' => $entity, 'propertyName' => $propertyName, 'args' => $args];
             }
         }
     }
 }
开发者ID:pmill,项目名称:doctrine-rest-api,代码行数:20,代码来源:PostUpdateValueListener.php

示例6: preUpdate

 /**
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $annotationReader = $this->getReaderFromEntityManager($args->getEntityManager());
     $entity = $args->getEntity();
     $changeSet = $args->getEntityChangeSet();
     $reflObject = new \ReflectionObject($entity);
     foreach ($changeSet as $propertyName => $values) {
         $property = $reflObject->getProperty($propertyName);
         /** @var PreUpdate $annotation */
         if ($annotation = $annotationReader->getPropertyAnnotation($property, PreUpdate::class)) {
             $className = $annotation->value;
             if (is_subclass_of($className, HandlerInterface::class)) {
                 /** @var HandlerInterface $propertySubscriber */
                 $propertySubscriber = new $className();
                 $propertySubscriber->handle($entity, $propertyName, $args);
             }
         }
     }
 }
开发者ID:pmill,项目名称:doctrine-rest-api,代码行数:22,代码来源:PreUpdateValueListener.php

示例7: preUpdate

 public function preUpdate(\Doctrine\ORM\Event\PreUpdateEventArgs $eventArgs)
 {
     if ($eventArgs->getEntity() instanceof User) {
         if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField('phone') || $eventArgs->hasChangedField('adresse') || $eventArgs->hasChangedField('ville') || $eventArgs->hasChangedField('zip')) {
             $service = $eventArgs->getEntity()->getService();
             if ($service != null) {
                 if ($service->getChefService()) {
                     $mail = $service->getChefService()->getEmail();
                 } else {
                     $mail = $service->getEmail();
                 }
             } else {
                 $mail = 'luciem92@gmail.com';
             }
             /**
              * TODO setFrom
              */
             $message = \Swift_Message::newInstance()->setSubject('Changements dans le profil de ' . $eventArgs->getEntity())->setFrom('send@example.com')->setTo('luciem92@gmail.com')->addCc($mail)->setBody($this->getMailBody($eventArgs->getEntityChangeSet(), $eventArgs->getEntity()), 'text/html');
             $this->mailer->send($message);
         }
     }
 }
开发者ID:luciemannechez,项目名称:projet-intranet_hopital,代码行数:22,代码来源:editProfileListener.php

示例8: 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());
         // local media is soft-deleted or soft-delete is reverted
         $changeSet = $eventArgs->getEntityChangeSet();
         if (isset($changeSet['deleted']) && $entity->getLocation() === 'local') {
             $deleted = !$changeSet['deleted'][0] && $changeSet['deleted'][1];
             $reverted = $changeSet['deleted'][0] && !$changeSet['deleted'][1];
             if ($deleted || $reverted) {
                 $oldFileUrl = $entity->getUrl();
                 $newFileName = $reverted ? $entity->getOriginalFilename() : uniqid();
                 $newFileUrl = dirname($oldFileUrl) . '/' . $newFileName . '.' . pathinfo($oldFileUrl, PATHINFO_EXTENSION);
                 $entity->setUrl($newFileUrl);
                 $this->fileUrlMap[$newFileUrl] = $oldFileUrl;
             }
         }
     }
 }
开发者ID:bakie,项目名称:KunstmaanBundlesCMS,代码行数:27,代码来源:DoctrineMediaListener.php

示例9: getOldValues

 private function getOldValues(PreUpdateEventArgs $event)
 {
     $oldValues = [];
     foreach ($event->getEntityChangeSet() as $name => $field) {
         if (false !== strpos($name, '.')) {
             continue;
         }
         $oldValues[$name] = $field[0];
     }
     return $oldValues ?: null;
 }
开发者ID:atom-azimov,项目名称:uploader,代码行数:11,代码来源:ORMListener.php

示例10: preUpdate

 /**
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     if (!$this->enabled) {
         return;
     }
     $entity = $args->getEntity();
     $entityClass = ClassUtils::getClass($entity);
     $event = ProcessTrigger::EVENT_UPDATE;
     if (!$this->triggerCache->hasTrigger($entityClass, $event)) {
         return;
     }
     $entityTriggers = $this->getTriggers($entityClass, $event);
     foreach ($entityTriggers as $trigger) {
         $this->scheduleProcess($trigger, $entity);
     }
     foreach (array_keys($args->getEntityChangeSet()) as $field) {
         $fieldTriggers = $this->getTriggers($entityClass, $event, $field);
         foreach ($fieldTriggers as $trigger) {
             $oldValue = $args->getOldValue($field);
             $newValue = $args->getNewValue($field);
             if ($newValue != $oldValue) {
                 $this->scheduleProcess($trigger, $entity, $oldValue, $newValue);
             }
         }
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:29,代码来源:ProcessCollectorListener.php

示例11: getOldValues

 private function getOldValues(PreUpdateEventArgs $event, $fieldName)
 {
     $oldValue = [];
     $fieldLength = strlen($fieldName) + 1;
     foreach ($event->getEntityChangeSet() as $name => $field) {
         if (false === strpos($name, $fieldName)) {
             continue;
         }
         $oldValue[substr($name, $fieldLength)] = $field[0];
     }
     return $oldValue ?: null;
 }
开发者ID:atom-azimov,项目名称:uploader,代码行数:12,代码来源:ORMEmbeddableListener.php

示例12: preUpdate

 /**
  * Invoked before the entity is updated.
  *
  * @ORM\PreUpdate
  *
  * @param PreUpdateEventArgs $event
  */
 public function preUpdate(PreUpdateEventArgs $event)
 {
     $excludedFields = ['lastLogin', 'loginCount'];
     if (array_diff_key($event->getEntityChangeSet(), array_flip($excludedFields))) {
         $this->updatedAt = new \DateTime('now', new \DateTimeZone('UTC'));
     }
 }
开发者ID:eltrino,项目名称:platform,代码行数:14,代码来源:User.php

示例13: preUpdate

 /**
  * @ORM\PreUpdate
  * @param PreUpdateEventArgs $event
  */
 public function preUpdate(PreUpdateEventArgs $event)
 {
     if (!$this->isApproved()) {
         return;
     }
     $changes = $event->getEntityChangeSet();
     if ($changes) {
         $changes = array_keys($changes);
         foreach ($changes as $field) {
             if (!in_array($field, ['isApproved', 'contactName', 'position', 'phone'])) {
                 $this->setIsApproved(false);
                 break;
             }
         }
     }
 }
开发者ID:bzis,项目名称:zomba,代码行数:20,代码来源:Company.php

示例14: preUpdate

 /**
  * Dispatch entity.update on preUpdate.
  *
  * @param Doctrine\ORM\Event\PreUpdateEventArgs $args
  * @return void
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entityName = $this->getEntityName($args->getEntity());
     $this->events["{$entityName}.update"] = new GenericEvent($args->getEntity(), array('id' => $this->getEntityId($args->getEntity(), $args->getEntityManager()), 'diff' => $args->getEntityChangeSet(), 'title' => $this->getEntityTitle($args->getEntity())));
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:11,代码来源:EventDispatcherProxy.php

示例15: preUpdate

 /**
  * Pre update event handler
  *
  * @ORM\PreUpdate
  *
  * @param PreUpdateEventArgs $event
  */
 public function preUpdate(PreUpdateEventArgs $event)
 {
     // prevent invoke update query if changesets updatedAt, createdAt field
     $excludedFields = ['createdAt', 'updatedAt'];
     if (array_diff_key($event->getEntityChangeSet(), array_flip($excludedFields))) {
         $this->updatedAt = new \DateTime('now', new \DateTimeZone('UTC'));
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:Organization.php


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