/** * @param Form $form * @param $form->values */ private function formSubmitted(Form $form) { /** @var PagesEntity $pageParent */ $pageParent = $this->pagesRepository->get($form->values->parent); $this->pagesRepository->begin(); $this->pagesRepository->prepareBeforeAdd($pageParent); $this->page = new PagesEntity(); $this->page->level($pageParent->level() + 1); $this->page->lft($pageParent->rgt()); $this->page->rgt($pageParent->rgt() + 1); $this->page->parent($pageParent->id()); $this->page->date(new DateTime()); $this->page->upDate(new DateTime()); $this->page->name($form->values->name); $this->page->inMenu(json_encode($form->values->inMenu)); $this->page->menuTitle($form->values->menuTitle); $this->page->perex($form->values->perex); $this->page->text($form->values->text); $this->page->pictureName($form->values->pictureName); $this->page->pictureDescription($form->values->pictureDescription); $this->page->active($form->values->active); $this->page->onHomepage($form->values->onHomepage); $this->page->secret($form->values->secret); $this->page->title($form->values->title); $this->page->description($form->values->description); $this->page->keywords($form->values->keywords); $this->page->secretText($form->values->secretText); $this->page->galleryIds(json_encode($form->values->galleryIds)); $this->page->upDate(new DateTime()); $this->getUrl($form->values); $this->pagesRepository->commit(); }
/** * @param $id */ public function handleInTopMenu($id) { $this->page = $this->pagesRepository->get($id); $items = json_decode($this->page->inMenu(), true); $key = array_search('topMenu', $items); if (is_numeric($key)) { unset($items[$key]); } else { array_push($items, 'topMenu'); } $this->page->inMenu(json_encode($items)); $this->pagesRepository->save($this->page); if (!$this->isAjax()) { $this->redirect('default'); } $this->redrawControl(); }