當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。