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


PHP PreUpdateEventArgs::getEntityManager方法代码示例

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


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

示例3: preUpdate

 public function preUpdate(PreUpdateEventArgs $args)
 {
     //return;
     $em = $args->getEntityManager();
     $entity = $args->getEntity();
     if ($entity instanceof Invoice && $entity->needsNumber()) {
         $entity->setNumber($em->getRepository('SiwappInvoiceBundle:Invoice')->getNextNumber($entity->getSerie()));
     }
 }
开发者ID:rvdavid,项目名称:siwapp-sf2,代码行数:9,代码来源:InvoiceSaveListener.php

示例4: preUpdate

 /**
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     if (!$this->isContactEntity($entity)) {
         return;
     }
     /** @var Contact $entity */
     $this->setUpdatedProperties($entity, $args->getEntityManager(), true);
 }
开发者ID:dairdr,项目名称:crm,代码行数:12,代码来源:ContactListener.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

 /** @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

示例7: preUpdate

 /**
  * Prepares all Files linked to an Entity before updating the Files and
  * persisting the changes to the database
  * Once prepared Doctrine UnitOfWork is checked for changes
  * to make sure the changes here are saved when it is flushed.
  * 
  * Called on the preUpdate doctrine event.
  *
  * @param \Doctrine\ORM\Event\PreUpdateEventArgs $args
  * 
  * @return void
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     if (!($entity = $args->getEntity()) instanceof FileUpload) {
         return;
     }
     // Prepare multiple Files
     $this->prePersistFilePreparation($entity);
     // Recompute the change set for the Entity and Files. Makes sure the changes are saved properly
     $this->recomputeChangeSetForEntity($entity, $args->getEntityManager());
 }
开发者ID:RavenB,项目名称:corvus,代码行数:22,代码来源:FileUploader.php

示例8: preUpdate

 /**
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     if (!$this->isActivityListEntity($entity)) {
         return;
     }
     /** @var ActivityList $entity */
     if ($this->isDateUpdatable($entity)) {
         $this->setUpdatedProperties($entity, $args->getEntityManager(), true);
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:14,代码来源:ActivityListChangesListener.php

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

示例10: preUpdate

 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     $issue = $eventArgs->getEntity();
     $entityManager = $eventArgs->getEntityManager();
     if ($issue instanceof Issue) {
         $user = $this->container->get('security.context')->getToken()->getUser();
         if ($eventArgs->hasChangedField('status')) {
             $this->setActivity($issue, $user, Activity::CHANGE_ISSUE_STATUS, $entityManager, true);
         }
     }
 }
开发者ID:DenysZakharov,项目名称:task-tracker,代码行数:11,代码来源:ActivityEventListener.php

示例11: preUpdate

 /**
  * Set object updater
  *
  * @param PreUpdateEventArgs $args The event arguments
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $obj = $args->getEntity();
     $blameable = $this->driver->getBlameableAnnotation($obj);
     if (null !== $blameable) {
         $this->updateEntity($obj, $blameable);
         $em = $args->getEntityManager();
         $uow = $em->getUnitOfWork();
         $metadata = $em->getClassMetadata(get_class($obj));
         $uow->recomputeSingleEntityChangeSet($metadata, $obj);
     }
 }
开发者ID:rafaelgou,项目名称:PSSDoctrineExtensionsBundle,代码行数:17,代码来源:BlameableListener.php

示例12: preUpdate

 public function preUpdate(PreUpdateEventArgs $event)
 {
     $entity = $event->getEntity();
     if (!$entity instanceof User) {
         return;
     }
     $this->encodePassword($entity);
     // force the save
     $em = $event->getEntityManager();
     $md = $em->getClassMetadata('Smartburk\\Bundle\\MainBundle\\Entity\\Series');
     $em->getUnitOfWork()->recomputeSingleEntityChangeSet($md, $entity);
 }
开发者ID:vinodpanicker,项目名称:behat,代码行数:12,代码来源:UserPasswordEncoderListener.php

示例13: preUpdate

 /**
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate($args)
 {
     $object = $args->getEntity();
     if ($object instanceof UserInterface) {
         $this->updateUserFields($object);
         // We are doing a update, so we must force Doctrine to update the
         // changeset in case we changed something above
         $em = $args->getEntityManager();
         $uow = $em->getUnitOfWork();
         $meta = $em->getClassMetadata(get_class($object));
         $uow->recomputeSingleEntityChangeSet($meta, $object);
     }
 }
开发者ID:eliberis,项目名称:academicbuddy,代码行数:16,代码来源:UserListener.php

示例14: preUpdate

 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();
     $entityManager = $args->getEntityManager();
     if (!$entity instanceof User) {
         return;
     }
     if ($args->hasChangedField('username')) {
         $class = ClassUtils::getRealClass($entity);
         $old_username = $args->getOldValue('username');
         $new_username = $args->getNewValue('username');
         $entityManager->getConnection()->update('acl_security_identities', array('identifier' => sprintf('%s-%s', $class, $new_username)), array('identifier' => sprintf('%s-%s', $class, $old_username)));
     }
 }
开发者ID:mapbender,项目名称:fom,代码行数:14,代码来源:UserSubscriber.php

示例15: preUpdate

 /**
  * Checks for updated reviews to update the average score of their site
  *
  * @param PreUpdateEventArgs $args
  */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $em = $args->getEntityManager();
     $entity = $args->getEntity();
     $uow = $em->getUnitOfWork();
     $entityClass = get_class($entity);
     if ($entityClass == 'Application\\YrchBundle\\Entity\\Review' && $this->needsUpdate($args)) {
         $oid = spl_object_hash($entity->getSite());
         if (!array_key_exists($oid, $this->_pendingSiteUpdates)) {
             $this->_pendingSiteUpdates[$oid] = $entity->getSite();
         }
         $this->_treatedSiteUpdates[$oid] = false;
     }
 }
开发者ID:Nenuial,项目名称:Yrch,代码行数:19,代码来源:ScoreListener.php


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