本文整理汇总了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);
}
}
}