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);
                 }
             }
         }
     }
 }
 public function getRoutesForObject($object)
 {
     if (!$this->isORM) {
         return $this->getOm()->getReferrers($object);
     } else {
         $contentResolver = new ContentCodeResolver();
         return $this->getOm()->getRepository('Symfony\\Cmf\\Bundle\\RoutingAutoBundle\\Doctrine\\Orm\\AutoRoute')->findBy(array('contentCode' => $contentResolver->getContentCode($object)));
     }
 }
 /**
  * @param $contentDocument
  * @return Collection
  */
 public function getActiveReferringAutoRoutes($contentDocument, $field = 'id')
 {
     return $this->em->getRepository('Symfony\\Cmf\\Bundle\\RoutingAutoBundle\\Doctrine\\Orm\\AutoRoute')->findBy(array('contentCode' => $this->contentResolver->getContentCode($contentDocument, $field), 'redirectRoute' => null));
 }
示例#4
0
 /**
  * Sets content as attached object and populates
  * 'contentCode' property.
  *
  * @param object $content
  * @param string $field
  * @return Route
  */
 public function setContent($content, $field = 'id')
 {
     $this->content = $content;
     $this->contentCode = $this->resolver->getContentCode($content, $field);
     return $this;
 }