• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Event\OnFlushEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onFlush

 public function onFlush(OnFlushEventArgs $args)
 {
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         /*
          * Check if the class is a child of the Meta class, the latter
          * handling the automatic createDate and modifiedDate methods.
          */
         if (!is_subclass_of($entity, 'CampaignChain\\CoreBundle\\Entity\\Meta')) {
             continue;
         }
         $logMetadata = $em->getClassMetadata(get_class($entity));
         $entity->setCreatedDate(new \DateTime('now', new \DateTimeZone('UTC')));
         $entity->setModifiedDate($entity->getCreatedDate());
         $em->persist($entity);
         $classMetadata = $em->getClassMetadata(get_class($entity));
         $uow->recomputeSingleEntityChangeSet($classMetadata, $entity);
     }
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         if (!is_subclass_of($entity, 'CampaignChain\\CoreBundle\\Entity\\Meta')) {
             continue;
         }
         $logMetadata = $em->getClassMetadata(get_class($entity));
         $entity->setModifiedDate(new \DateTime('now', new \DateTimeZone('UTC')));
     }
 }
开发者ID:CampaignChain,项目名称:core,代码行数:27,代码来源:DoctrineMetaListener.php


示例2: onFlush

 /**
  * Change cssHash of views when a widget is updated or deleted.
  *
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $this->em = $args->getEntityManager();
     $this->uow = $this->em->getUnitOfWork();
     $this->widgetRepo = $this->em->getRepository('Victoire\\Bundle\\WidgetBundle\\Entity\\Widget');
     $this->viewRepo = $this->em->getRepository('Victoire\\Bundle\\CoreBundle\\Entity\\View');
     $updatedEntities = $this->uow->getScheduledEntityUpdates();
     $deletedEntities = $this->uow->getScheduledEntityDeletions();
     //Update View's CSS and inheritors of updated and deleted widgets
     foreach (array_merge($updatedEntities, $deletedEntities) as $entity) {
         if (!$entity instanceof Widget) {
             continue;
         }
         $view = $entity->getView();
         $this->updateViewCss($view);
         $this->updateTemplateInheritorsCss($view);
     }
     //Remove CSS of deleted View and update its inheritors
     foreach ($deletedEntities as $entity) {
         if (!$entity instanceof View) {
             continue;
         }
         $this->viewCssBuilder->removeCssFile($entity->getCssHash());
         $this->updateTemplateInheritorsCss($entity);
     }
     //Update CSS of updated View and its inheritors
     foreach ($updatedEntities as $entity) {
         if (!$entity instanceof View) {
             continue;
         }
         $this->updateViewCss($entity);
         $this->updateTemplateInheritorsCss($entity);
     }
 }
开发者ID:global01,项目名称:victoire,代码行数:39,代码来源:WidgetSubscriber.php


示例3: onFlush

 public function onFlush(OnFlushEventArgs $args)
 {
     //echo "---preFlush".PHP_EOL;
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof CmsUser) {
             // Adds a phonenumber to every newly persisted CmsUser ...
             $phone = new CmsPhonenumber();
             $phone->phonenumber = 12345;
             // Update object model
             $entity->addPhonenumber($phone);
             // Invoke regular persist call
             $em->persist($phone);
             // Explicitly calculate the changeset since onFlush is raised
             // after changeset calculation!
             $uow->computeChangeSet($em->getClassMetadata(get_class($phone)), $phone);
             // Take a snapshot because the UoW wont do this for us, because
             // the UoW did not visit this collection.
             // Alternatively we could provide an ->addVisitedCollection() method
             // on the UoW.
             $entity->getPhonenumbers()->takeSnapshot();
         }
         /*foreach ($uow->getEntityChangeSet($entity) as $field => $change) {
                         list ($old, $new) = $change;
         
                         var_dump($old);
                     }*/
     }
 }
开发者ID:andreia,项目名称:doctrine,代码行数:30,代码来源:FlushEventTest.php


示例4: onFlush

 /**
  * @param OnFlushEventArgs $event
  */
 public function onFlush(OnFlushEventArgs $event)
 {
     $em = $event->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof User) {
             $userSettings = new UserSettings();
             $userSettings->setUser($entity);
             $em->persist($userSettings);
             $uow->computeChangeSet($em->getClassMetadata(UserSettings::clazz()), $userSettings);
         }
         if ($entity instanceof Group) {
             $groupSettings = new GroupSettings();
             $groupSettings->setGroup($entity);
             $em->persist($groupSettings);
             $uow->computeChangeSet($em->getClassMetadata(GroupSettings::clazz()), $groupSettings);
         }
     }
     foreach ($uow->getScheduledEntityDeletions() as $entity) {
         if ($entity instanceof User) {
             $query = $em->createQuery(sprintf('DELETE FROM %s us WHERE us.user = ?0', UserSettings::clazz()));
             $query->execute(array($entity));
         }
         if ($entity instanceof Group) {
             $query = $em->createQuery(sprintf('DELETE FROM %s us WHERE us.group = ?0', GroupSettings::clazz()));
             $query->execute(array($entity));
         }
     }
 }
开发者ID:modera,项目名称:foundation,代码行数:32,代码来源:SettingsEntityManagingListener.php


示例5: onFlush

 public function onFlush(OnFlushEventArgs $args)
 {
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     $entities = array_merge($uow->getScheduledEntityInsertions(), $uow->getScheduledEntityUpdates());
     foreach ($entities as $entity) {
         if (!$entity instanceof Searchable) {
             continue;
         }
         $this->_updates[] = $entity;
     }
     $entities = array_merge($uow->getScheduledEntityDeletions());
     foreach ($entities as $entity) {
         if (!$entity instanceof Searchable) {
             continue;
         }
         $this->_deletions[] = $entity;
     }
     if (count($this->_deletions)) {
         $indexes = $em->getRepository('Chalk\\Core\\Index')->entities($this->_deletions);
         foreach ($indexes as $index) {
             $em->remove($index);
         }
         $this->_deletions = [];
     }
 }
开发者ID:jacksleight,项目名称:chalk,代码行数:26,代码来源:Listener.php


示例6: onFlush

 /**
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $uow = $args->getEntityManager()->getUnitOfWork();
     foreach ($uow->getScheduledEntityDeletions() as $entity) {
         $this->addPendingUpdates($entity);
     }
 }
开发者ID:qrz-io,项目名称:pim-community-dev,代码行数:10,代码来源:ProductRelatedEntityRemovalSubscriber.php


示例7: onFlush

 public function onFlush(OnFlushEventArgs $args)
 {
     /** @var $om EntityManager */
     $om = $args->getEntityManager();
     $uow = $om->getUnitOfWork();
     $arm = $this->getAutoRouteManager();
     $this->contentResolver->setEntityManager($om);
     $this->insertions = $uow->getScheduledEntityInsertions();
     $scheduledUpdates = $uow->getScheduledEntityUpdates();
     //        $updates = array_merge($scheduledInserts, $scheduledUpdates);
     foreach ($scheduledUpdates as $document) {
         $this->handleInsertOrUpdate($document, $arm, $om, $uow);
     }
     $removes = $uow->getScheduledCollectionDeletions();
     foreach ($removes as $document) {
         if ($this->isAutoRouteable($document)) {
             $referrers = $om->getRepository('Symfony\\Cmf\\Bundle\\RoutingAutoBundle\\Doctrine\\Orm\\AutoRoute')->findBy(array('contentCode' => $this->contentResolver->getContentCode($document)));
             if ($referrers) {
                 foreach ($referrers as $autoRoute) {
                     $uow->scheduleForDelete($autoRoute);
                 }
             }
         }
     }
 }
开发者ID:fredpeaks,项目名称:RoutingAutoBundle,代码行数:25,代码来源:AutoRouteListener.php


示例8: onFlush

 public function onFlush(OnFlushEventArgs $args)
 {
     if ($this->_isFlushing) {
         return;
     }
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     $entities = array_merge($uow->getScheduledEntityInsertions(), $uow->getScheduledEntityUpdates(), $uow->getScheduledEntityDeletions());
     foreach ($entities as $entity) {
         $structures = [];
         if ($entity instanceof Structure) {
             $structures[] = $entity;
         } else {
             if ($entity instanceof Node) {
                 $structures[] = $entity->structure;
             } else {
                 if ($entity instanceof Content) {
                     foreach ($entity->nodes as $node) {
                         $structures[] = $node->structure;
                     }
                 } else {
                     continue;
                 }
             }
         }
         foreach ($structures as $structure) {
             if (!in_array($structure, $this->_structures, true)) {
                 $this->_structures[] = $structure;
             }
         }
     }
 }
开发者ID:jacksleight,项目名称:chalk,代码行数:32,代码来源:Listener.php


示例9: onFlush

 /**
  * @param OnFlushEventArgs $eventArgs
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $em = $eventArgs->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof Customer) {
             $this->getLogger()->info('[CustomerConnectorSubscriber][onFlush] Scheduled for insertion');
             $this->getSubscriptionAdapter()->createCustomer($entity);
             $this->persistAndRecomputeChangeset($em, $uow, $entity);
         }
     }
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof Customer) {
             $this->getLogger()->info('[CustomerConnectorSubscriber][onFlush] Scheduled for updates');
             $changeset = $uow->getEntityChangeSet($entity);
             $keys = array('email', 'firstName', 'lastName', 'companyName', 'billingCity', 'billingCountry', 'billingStreet');
             if ($this->arrayHasKeys($changeset, $keys)) {
                 $entity->setSubscriptionSynced(false);
             }
             if ($entity->getSubscriptionCustomerId() && $entity->isSubscriptionSynced() == false) {
                 $this->getSubscriptionAdapter()->updateCustomer($entity);
             } elseif (is_null($entity->getSubscriptionCustomerId())) {
                 $this->getSubscriptionAdapter()->createCustomer($entity);
             }
             $this->persistAndRecomputeChangeset($em, $uow, $entity);
         }
     }
 }
开发者ID:vik0803,项目名称:SubscriptionBundle,代码行数:31,代码来源:CustomerConnectorSubscriber.php


示例10: onFlush

 /**
  * Upload the files on new and updated entities
  *
  * @param OnFlushEventArgs $eventArgs
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $em = $eventArgs->getEntityManager();
     $uow = $em->getUnitOfWork();
     $entities = array_merge($uow->getScheduledEntityInsertions(), $uow->getScheduledEntityUpdates());
     foreach ($entities as $entity) {
         $classMetadata = $em->getClassMetadata(get_class($entity));
         if (!$this->isEntitySupported($classMetadata)) {
             continue;
         }
         if (0 === count($entity->getUploadableFields())) {
             continue;
         }
         // If there is an error when moving the file, an exception will
         // be automatically thrown by move(). This will properly prevent
         // the entity from being persisted to the database on error
         foreach ($entity->getUploadableFields() as $field => $uploadDir) {
             // If a file has been uploaded
             if (null !== $entity->getUploadField($field)) {
                 // Generate the filename
                 $filename = $entity->generateFilename($entity->getUploadField($field), $field);
                 // Set the filename
                 $entity->setUploadPath($field, $filename);
                 $entity->getUploadField($field)->move($entity->getUploadRootDir($field), $entity->getUploadPath($field));
                 // Remove the previous file if necessary
                 $entity->removeUpload($field, true);
                 $entity->unsetUploadField($field);
             }
         }
         $em->persist($entity);
         $uow->recomputeSingleEntityChangeSet($classMetadata, $entity);
     }
 }
开发者ID:smart85,项目名称:UnifikDoctrineBehaviorsBundle,代码行数:38,代码来源:UploadableListener.php


示例11: onFlush

 /**
  * @param OnFlushEventArgs $args
  * @return mixed|void
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $em = $args->getEntityManager();
     $unitOfWork = $em->getUnitOfWork();
     foreach ($unitOfWork->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof PageInterface) {
             if ($contentRoute = $entity->getContentRoute()) {
                 $contentRoute->setPath(PageHelper::getPageRoutePath($entity->getPath()));
                 $em->persist($contentRoute);
                 $unitOfWork->computeChangeSet($em->getClassMetadata(get_class($contentRoute)), $contentRoute);
                 foreach ($entity->getAllChildren() as $child) {
                     $contentRoute = $child->getContentRoute();
                     $contentRoute->setPath(PageHelper::getPageRoutePath($child->getPath()));
                     $em->persist($contentRoute);
                     $unitOfWork->computeChangeSet($em->getClassMetadata(get_class($contentRoute)), $contentRoute);
                     if ($entity->getStatus() == Page::STATUS_PUBLISHED) {
                         if ($childSnapshot = $child->getSnapshot()) {
                             $snapshotRoute = $childSnapshot->getContentRoute();
                             $newPath = PageHelper::getPageRoutePath($child->getPath());
                             $snapshotRoute->setPath($newPath);
                             $childSnapshot->setPath($newPath);
                             $em->persist($childSnapshot);
                             $em->persist($snapshotRoute);
                             $unitOfWork->computeChangeSet($em->getClassMetadata(get_class($childSnapshot)), $childSnapshot);
                             $unitOfWork->computeChangeSet($em->getClassMetadata(get_class($snapshotRoute)), $snapshotRoute);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:networking,项目名称:init-cms-bundle,代码行数:36,代码来源:PageListener.php


示例12: onFlush

 public function onFlush(OnFlushEventArgs $args)
 {
     if (!$this->container->has('orocrm_contact.contact.manager')) {
         return;
     }
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     $insertedEntities = $uow->getScheduledEntityInsertions();
     $updatedEntities = $uow->getScheduledEntityUpdates();
     $entities = array_merge($insertedEntities, $updatedEntities);
     foreach ($entities as $entity) {
         if (!$entity instanceof DiamanteUser) {
             continue;
         }
         $contactManager = $this->container->get('orocrm_contact.contact.manager');
         $contact = $contactManager->getRepository()->findOneBy(['email' => $entity->getEmail()]);
         if (empty($contact)) {
             continue;
         }
         if ($entity->getFirstName() == null) {
             $entity->setFirstName($contact->getFirstName());
         }
         if ($entity->getLastName() == null) {
             $entity->setLastName($contact->getLastName());
         }
         try {
             $em->persist($entity);
             $md = $em->getClassMetadata(get_class($entity));
             $uow->recomputeSingleEntityChangeSet($md, $entity);
         } catch (\Exception $e) {
             $this->container->get('monolog.logger.diamante')->addWarning(sprintf('Error saving Contact Information for Diamante User with email: %s', $entity->getEmail()));
         }
     }
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:34,代码来源:DiamanteUserListener.php


示例13: onFlush

 /**
  * @param OnFlushEventArgs $event
  * @param ContainerInterface $container
  * @return mixed
  */
 public function onFlush(OnFlushEventArgs $event, ContainerInterface $container)
 {
     $this->timelineRepository = $container->get('diamante.ticket_timeline.repository');
     $em = $event->getEntityManager();
     $uof = $em->getUnitOfWork();
     foreach ($uof->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof Ticket && (string) $entity->getStatus()->getValue() === 'new') {
             $this->increaseNewCounter();
             $this->persistCurrentDayRecord($em);
         }
     }
     foreach ($uof->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof Ticket) {
             $changes = $uof->getEntityChangeSet($entity);
             if (!isset($changes['status'])) {
                 continue;
             }
             $from = $changes['status'][0]->getValue();
             $to = $changes['status'][1]->getValue();
             if (isset($changes['status']) && $from !== $to) {
                 if ($to === 'closed') {
                     $this->increaseClosedCounter();
                     $this->persistCurrentDayRecord($em);
                 }
                 if ($from === 'closed') {
                     $this->increaseReopenCounter();
                     $this->persistCurrentDayRecord($em);
                 }
             }
         }
     }
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:37,代码来源:ReportTimelineServiceImpl.php


示例14: onFlush

 /**
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     $emails = [];
     foreach ($uow->getScheduledEntityInsertions() as $oid => $entity) {
         if ($entity instanceof EmailUser) {
             /*
              * Collect already flushed emails with bodies and later check
              * if there is new binding to mailbox.
              * (email was sent from the system and now mailbox is synchronized)
              */
             $email = $entity->getEmail();
             if ($email && $email->getId() && $email->getEmailBody() && $entity->getMailboxOwner()) {
                 $emails[$email->getId()] = $email;
             }
         } elseif ($entity instanceof EmailBody) {
             $this->emailBodies[$oid] = $entity;
         }
     }
     if ($emails) {
         $emailsToProcess = $this->filterEmailsWithNewlyBoundMailboxes($em, $emails);
         foreach ($emailsToProcess as $email) {
             $this->emailBodies[spl_object_hash($email->getEmailBody())] = $email->getEmailBody();
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:30,代码来源:MailboxEmailListener.php


示例15: onFlush

 /**
  * @param OnFlushEventArgs $eventArgs
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $em = $eventArgs->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         if ($entity instanceof Plan) {
             $this->getLogger()->info('[PlanConnectorSubscriber][onFlush] Scheduled for insertion');
             $this->getSubscriptionAdapter()->createPlan($entity);
             $this->persistAndRecomputeChangeset($em, $uow, $entity);
         }
     }
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof Plan) {
             $changeset = $uow->getEntityChangeSet($entity);
             $keys = array('amount', 'trialPeriod', 'trialPeriodUnit');
             if ($this->arrayHasKeys($changeset, $keys)) {
                 $entity->setSubscriptionSynced(false);
             }
             $this->getLogger()->info('[PlanConnectorSubscriber][onFlush] Scheduled for updates');
             if ($entity->getSubscriptionPlanId() && $entity->isSubscriptionSynced() == false) {
                 $this->getSubscriptionAdapter()->updatePlan($entity);
             } elseif (is_null($entity->getSubscriptionPlanId())) {
                 $this->getSubscriptionAdapter()->createPlan($entity);
             }
             $this->persistAndRecomputeChangeset($em, $uow, $entity);
         }
     }
 }
开发者ID:vik0803,项目名称:SubscriptionBundle,代码行数:31,代码来源:PlanConnectorSubscriber.php


示例16: onFlush

 /**
  * @param OnFlushEventArgs $event
  */
 public function onFlush(OnFlushEventArgs $event)
 {
     if (!$this->enabled) {
         return;
     }
     $this->loggableManager->handleLoggable($event->getEntityManager());
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:EntityListener.php


示例17: onFlush

 /**
  * The onFlush method will reassign loans to loan officer sites if they have one
  * @param OnFlushEventArgs $eventArgs
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $em = $eventArgs->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof LoanApplication) {
             // reassign the loan application to the LO site
             $lo = $entity->getLoanOfficer();
             //echo 'here 1';
             if (isset($lo)) {
                 $hasSite = $lo->hasSite();
                 if ($hasSite) {
                     // check if they are different
                     //print_r('Loan ID: ' . $entity->getId() . '---'. $lo->getOfficerSite()->getId() . ':' . $entity->getSite()->getId() . ' ');
                     $additionalSiteIds = array();
                     $additionalSites = $entity->getAdditionalSite();
                     if (isset($additionalSites)) {
                         foreach ($entity->getAdditionalSite() as $site) {
                             array_push($additionalSiteIds, $site->getId());
                         }
                     }
                     //print_r($additionalSiteIds);
                     if ($lo->getOfficerSite()->getId() != $entity->getSite()->getId() && !in_array($lo->getOfficerSite()->getId(), $additionalSiteIds)) {
                         $entity->addAdditionalSite($lo->getOfficerSite());
                         $uow->persist($entity);
                         //print_r('add site');
                     }
                 }
             }
         }
     }
     $uow->computeChangeSets();
 }
开发者ID:eric19h,项目名称:turbulent-wookie,代码行数:37,代码来源:LoanApplicationListener.php


示例18: onFlush

    /**
     * @param \Doctrine\Common\EventArgs
	 * @return void
     */
    public function onFlush(\Doctrine\ORM\Event\OnFlushEventArgs $args)
	{
		$em = $args->getEntityManager();
        $uow = $em->getUnitOfWork();

		// Process updated entities
        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            if ($entity instanceof IVersionableEntity) {
                $this->takeSnapshot($em, $entity);
            }
        }

		// Process removed entities
		$sources = array();
		foreach ($uow->getScheduledEntityDeletions() as $entity) {
			if ($entity instanceof IVersionableEntity) {
                $sources[get_class($entity)][] = $entity->getId();
            }
		}
		if ($sources) {
			$qb = $em->createQueryBuilder()
				->delete('Nella\Doctrine\Listeners\VersionEntity', 'v');
			foreach ($sources as $class => $ids) {
				$qb->andWhere('v.entityClass = :class', $qb->expr()->in('v.entityId', $ids))->setParameter('class', $class);
			}
			$qb->getQuery()->execute();
		}
    }
开发者ID:norbe,项目名称:framework,代码行数:32,代码来源:Version.php


示例19: onFlush

 /**
  * @link http://docs.doctrine-project.org/en/latest/reference/events.html
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     $primitivelyChangedEntities = new SplObjectStorage();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         if (property_exists($entity, 'created_by')) {
             $entity->created_by = $this->identifier;
             $primitivelyChangedEntities->attach($entity);
         }
         if (property_exists($entity, 'updated_by')) {
             $entity->updated_by = $this->identifier;
             $primitivelyChangedEntities->attach($entity);
         }
     }
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         if (property_exists($entity, 'updated_by')) {
             $entity->updated_by = $this->identifier;
             $primitivelyChangedEntities->attach($entity);
         }
     }
     foreach ($primitivelyChangedEntities as $entity) {
         $meta = $em->getClassMetadata(get_class($entity));
         $uow->recomputeSingleEntityChangeSet($meta, $entity);
     }
 }
开发者ID:tillikum,项目名称:tillikum-core-module,代码行数:29,代码来源:Audit.php


示例20: onFlush

 /**
  * Collect changes that were done
  * Generates tags and store in protected variable
  *
  * @param OnFlushEventArgs $event
  */
 public function onFlush(OnFlushEventArgs $event)
 {
     if (!$this->isApplicationInstalled) {
         return;
     }
     $em = $event->getEntityManager();
     $uow = $em->getUnitOfWork();
     $entities = array_merge($uow->getScheduledEntityDeletions(), $uow->getScheduledEntityInsertions(), $uow->getScheduledEntityUpdates());
     $collections = array_merge($uow->getScheduledCollectionUpdates(), $uow->getScheduledCollectionDeletions());
     foreach ($collections as $collection) {
         $owner = $collection->getOwner();
         if (!in_array($owner, $entities, true)) {
             $entities[] = $owner;
         }
     }
     $generator = $this->sender->getGenerator();
     foreach ($entities as $entity) {
         if (!in_array(ClassUtils::getClass($entity), $this->skipTrackingFor)) {
             // invalidate collection view pages only when entity has been added or removed
             $includeCollectionTag = $uow->isScheduledForInsert($entity) || $uow->isScheduledForDelete($entity);
             $this->collectedTags = array_merge($this->collectedTags, $generator->generate($entity, $includeCollectionTag));
         }
     }
     $this->collectedTags = array_unique($this->collectedTags);
 }
开发者ID:xamin123,项目名称:platform,代码行数:31,代码来源:DoctrineTagEventListener.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Event\PreUpdateEventArgs类代码示例发布时间:2022-05-23
下一篇:
PHP Event\LoadClassMetadataEventArgs类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap