/**
  * {@inheritdoc}
  */
 public function buildReference(View $view, EntityManager $em)
 {
     $referenceId = ViewReferenceHelper::generateViewReferenceId($view);
     $viewReference = new ViewReference();
     $viewReference->setId($referenceId);
     $viewReference->setLocale($view->getCurrentLocale());
     $viewReference->setName($view->getName());
     $viewReference->setViewId($view->getId());
     $viewReference->setSlug($view->getSlug());
     $viewReference->setViewNamespace($em->getClassMetadata(get_class($view))->name);
     if ($parent = $view->getParent()) {
         $viewReference->setParent(ViewReferenceHelper::generateViewReferenceId($parent));
     }
     return $viewReference;
 }
 /**
  * {@inheritdoc}
  */
 public function buildReference(View $view, EntityManager $em)
 {
     $referenceId = ViewReferenceHelper::generateViewReferenceId($view);
     $viewReference = new ViewReference();
     $viewReference->setId($referenceId);
     $viewReference->setLocale($view->getLocale());
     $viewReference->setName($view->getName());
     $viewReference->setViewId($view->getId());
     $viewReference->setSlug($view->isHomepage() ? '' : $view->getSlug());
     $viewReference->setViewNamespace(get_class($view));
     return $viewReference;
 }
 /**
  * {@inheritdoc}
  */
 public function buildReference(View $view, EntityManager $em)
 {
     /* @var Page $view */
     $referenceId = ViewReferenceHelper::generateViewReferenceId($view);
     $viewReference = new ViewReference();
     $viewReference->setId($referenceId);
     $viewReference->setLocale($view->getCurrentLocale());
     $viewReference->setName($view->getName());
     $viewReference->setViewId($view->getId());
     $viewReference->setSlug($view->isHomepage() ? '' : $view->getSlug());
     $viewReference->setViewNamespace(ClassUtils::getClass($view));
     if ($parent = $view->getParent()) {
         $parent->translate($view->getCurrentLocale());
         $viewReference->setParent(ViewReferenceHelper::generateViewReferenceId($parent));
     }
     return $viewReference;
 }
Beispiel #4
0
 /**
  * read the cache to find entity according tu given url.
  *
  * @param BusinessPageReference $viewReference
  *
  * @return object|null
  */
 protected function findEntityByReference(ViewReference $viewReference)
 {
     if ($viewReference instanceof BusinessPageReference && !empty($viewReference->getEntityId())) {
         return $this->entityManager->getRepository($viewReference->getEntityNamespace())->findOneById($viewReference->getEntityId());
     }
 }
 /**
  * Remove an url for a viewReference with his reference in redis.
  *
  * @param ViewReference $viewReference
  */
 public function removeUrlForViewReference(ViewReference $viewReference)
 {
     $id = $viewReference->getId();
     if ($url = $this->repository->findValueForId('url', $id)) {
         $this->manager->removeUrl($url, $this->repository->findValueForId('locale', $id));
     }
 }