Example #1
0
 public function __construct(User $user, PageFacade $pageFacade, ITranslator $translator, LocaleFacade $localeFacade, TagFormFactory $tagFormFactory, IPageTagsPickingControlFactory $articleTagsPickingControlFactory)
 {
     $this->userEntity = $user;
     $this->pageFacade = $pageFacade;
     $this->translator = $translator;
     $this->localeFacade = $localeFacade;
     $this->tagFormFactory = $tagFormFactory;
     $this->pageTagsPickingControlFactory = $articleTagsPickingControlFactory;
     $this->prepareLocales($this->localeFacade->findAllLocales());
 }
Example #2
0
 /**
  * @param array $values
  * @param Page|null $page
  * @return Page
  * @throws UrlAlreadyExistsException
  * @throws LocaleNotFoundException
  * @throws PageTitleAlreadyExistsException
  * @throws PageIntroHtmlLengthException
  */
 private function createNewPage(array $values, Page $page = null)
 {
     $this->em->beginTransaction();
     $url = $this->establishPageUrl($values['title'], $values['url']);
     $url = $this->urlFacade->saveUrl($url);
     // still needs internalID to be set! (next in code)
     $locale = $this->localeFacade->getByName($values['lang']);
     if ($locale === null) {
         throw new LocaleNotFoundException();
     }
     if ($page === null) {
         $page = new Page($values['title'], $values['intro'], $values['text'], $url, $values['author'], $locale);
     }
     $this->fillPageEntity($values, $page);
     /** @var Page $page */
     $page = $this->em->safePersist($page);
     if ($page === false) {
         throw new PageTitleAlreadyExistsException();
     }
     $url->setInternalId($page->getId());
     $this->em->persist($url);
     $this->addTags2Page($values['tags'], $page);
     $this->em->persist($page);
     $this->em->flush();
     $this->em->commit();
     return $page;
 }
Example #3
0
 private function loadLocales()
 {
     if ($this->locales !== null) {
         return;
     }
     $localization = $this->localeFacade->findAllLocales();
     foreach ($localization as $name => $locale) {
         $this->locales[$locale['code']] = $locale['default'];
     }
 }
Example #4
0
 public function __construct(LocaleFacade $localeFacade, ITranslator $translator, Session $session)
 {
     $this->translator = $translator;
     $this->session = $session->getSection('cms_localization');
     $this->prepareLocales($localeFacade->findAllLocales());
 }