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


PHP UnitOfWork::scheduleForDelete方法代码示例

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


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

示例1: updateRouting

 /**
  * Schedule updates for routing
  *
  * @param EntityManager $em
  * @param UnitOfWork $uow
  */
 protected function updateRouting(EntityManager $em, UnitOfWork $uow)
 {
     // 302 old routes to the new 200
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         if ($entity instanceof FieldableEntity) {
             $changeSet = $uow->getEntityChangeSet($entity);
             $oldRoute = $entity->getRoute();
             // Check if we have a route. If not, create one and continue
             if (!$oldRoute instanceof Route) {
                 // create the new route
                 $oldRoute = $this->getEntityRoute($entity);
                 $entity->setRoute($oldRoute);
                 $this->computeChangeSet($em, $oldRoute);
                 $this->recomputeSingleEntityChangeSet($em, $entity);
             }
             // Check if the route has been manually updated
             $newRoute = $this->getEntityRoute($entity);
             // if the route changed, update it
             if ($newRoute->getPath() !== $oldRoute->getPath()) {
                 // create the new route entity
                 $entity->setRoute($newRoute);
                 $this->computeChangeSet($em, $newRoute);
                 // set any old route to redirect to the new route
                 $this->redirectRoute($oldRoute);
                 $this->recomputeSingleEntityChangeSet($em, $oldRoute);
             }
             if (isset($changeSet['deletedOn'])) {
                 if ($changeSet['deletedOn'] instanceof \DateTime) {
                     // delete
                     $this->deletedRoute($oldRoute);
                     $this->recomputeSingleEntityChangeSet($em, $oldRoute);
                 } else {
                     // un-delete
                     $newRoute = $this->getEntityRoute($entity);
                     $entity->setRoute($newRoute);
                     $uow->scheduleForDelete($oldRoute);
                     $this->computeChangeSet($em, $newRoute);
                     $this->recomputeSingleEntityChangeSet($em, $oldRoute);
                 }
             }
             $em->persist($entity);
             $this->recomputeSingleEntityChangeSet($em, $entity);
         }
     }
 }
开发者ID:gravity-cms,项目名称:cms-bundle,代码行数:51,代码来源:NodeEventListener.php


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