Esempio n. 1
0
 /**
  * @param Form $form
  */
 public function configure(Form $form)
 {
     $form->addText('name', 'Name')->addRule($form::FILLED);
     $form->addText('domain', 'Domain')->addRule($form::FILLED);
     /** @var ManyToOne $page */
     $page = $form->addOneToOne('page', 'Page');
     $page->setQuery($this->pageRepository->createQueryBuilder('a')->orderBy('a.positionString', 'ASC'));
     $form->addSaveButton('Save');
 }
Esempio n. 2
0
 /**
  * @return AdminGrid
  */
 public function invoke()
 {
     $_this = $this;
     $adminGrid = new AdminGrid($this->pageRepository);
     $table = $adminGrid->getTable();
     $table->setModel(new Doctrine($this->pageRepository->createQueryBuilder('a')->addSelect('r')->innerJoin('a.mainRoute', 'r'), array('name' => 'r.name', 'created' => 'r.created', 'url' => 'r.url')));
     $table->addColumnText('name', 'Name')->setCustomRender(function ($entity) {
         return $entity->mainRoute->name;
     })->setSortable()->setFilterText()->setSuggestion();
     $table->getColumn('name')->getCellPrototype()->width = '50%';
     $table->addColumnText('url', 'URL')->setCustomRender(function ($entity) {
         return $entity->mainRoute->url;
     })->setSortable()->setFilterText()->setSuggestion();
     $table->getColumn('url')->getCellPrototype()->width = '25%';
     $table->addColumnText('language', 'Language')->getCellPrototype()->width = '25%';
     $adminGrid->onAttached[] = function (AdminGrid $table) use($_this) {
         $_this->onAttached($table);
     };
     return $adminGrid;
 }
Esempio n. 3
0
 public function getRoutes()
 {
     if ($this->page) {
         return $this->routeRepository->findBy(array('page' => $this->page));
     }
     $lang = $this->getLanguage();
     $ids = array();
     $pages = $this->pageRepository->createQueryBuilder('a')->where('(a.language IS NULL OR a.language = :lang)')->setParameter('lang', $lang->id)->getQuery()->getResult();
     foreach ($pages as $page) {
         if ($this->countRoutesByPage($page) <= $this->itemsLimit) {
             $ids[] = $page->id;
         }
     }
     return $this->routeRepository->createQueryBuilder('a')->andWhere('a.page IN (:ids)')->setParameter('ids', $ids)->andWhere('a.published = :true')->setParameter('true', TRUE)->getQuery()->getResult();
 }
Esempio n. 4
0
 /**
  * @return \CmsModule\Content\Entities\PageEntity
  */
 public function getRootPage()
 {
     return $this->extendedPage->rootPage ? $this->extendedPage->rootPage : $this->pageRepository->createQueryBuilder('a')->leftJoin('a.mainRoute', 'r')->where('r.parent IS NULL')->getQuery()->getSingleResult();
 }
Esempio n. 5
0
 /**
  * @param \CmsModule\Content\Entities\PageEntity $page
  * @return \Doctrine\ORM\QueryBuilder
  */
 private function getChildrenQb(\CmsModule\Content\Entities\PageEntity $page = NULL)
 {
     return $this->pageRepository->createQueryBuilder('a')->leftJoin('a.mainRoute', 'r')->andWhere('a.parent = :parent')->setParameter('parent', $page ? $page->id : NULL)->andWhere('(r.language IS NULL OR r.language = :language)')->setParameter('language', $this->presenter->language->id)->andWhere('a.published = :true')->andWhere('r.published = :true')->setParameter('true', TRUE)->orderBy('a.position', 'ASC');
 }