示例#1
0
 /**
  * @param Page $page
  */
 private function removePageUrl(Page $page)
 {
     /** @var Url $url */
     $url = $this->urlFacade->getByPath($page->getUrlPath());
     if ($url !== null) {
         $this->cache->clean([Cache::TAGS => $url->getCacheKey()]);
         $this->em->remove($url);
     }
 }
示例#2
0
 /**
  * @param string $newUrlAddress
  * @param Page $page
  * @return Url
  * @throws UrlAlreadyExistsException
  */
 private function redirectPageToUrl($newUrlAddress, Page $page)
 {
     $newUrlEntity = $this->createUrl($newUrlAddress);
     $newUrlEntity->setInternalId($page->getId());
     // if we first try to save url entity, the current transaction is marked for
     // rollback only if there is unique constraint violation.
     $newUrl = $this->urlFacade->getByPath($newUrlEntity->getUrlPath());
     if ($newUrl === null) {
         $newUrl = $this->urlFacade->saveUrl($newUrlEntity);
     }
     $oldUrl = $this->urlFacade->getById($page->getUrlId());
     $this->urlFacade->linkUrls($oldUrl, $newUrl);
     return $newUrl;
 }