Example #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);
     }
 }
Example #2
0
 /**
  * @param $tagID
  * @throws \Exception
  */
 public function remove($tagID)
 {
     try {
         $this->em->beginTransaction();
         /** @var Tag $tag */
         $tag = $this->tagRepository->find($tagID);
         if ($tag === null) {
             $this->em->commit();
             return;
         }
         $tagSearchUrl = $this->urlFacade->getUrl('Pages:Front:Search', 'tag', $tag->getId());
         $this->em->remove($tag);
         $this->em->remove($tagSearchUrl);
         $this->em->flush();
         $this->em->commit();
         $this->onSuccessTagRemoval($tag, $tagID);
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         throw $e;
     }
 }
Example #3
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;
 }
Example #4
0
 /**
  * @param Tag $tag
  */
 private function createUrl(Tag $tag)
 {
     $url = UrlGenerator::create(sprintf('search/%s', $tag->getName()), 'Pages:Front:Search', 'tag', $tag->getId());
     $this->urlFacade->saveUrl($url);
 }