Exemplo n.º 1
0
 public function getRouteCollectionForRequest(Request $request)
 {
     $collection = new RouteCollection();
     $path = $request->getPathInfo();
     if ('/-1' === $path) {
         return $collection;
     }
     $slugs = explode('/', trim($path, '/'));
     $slug = array_pop($slugs);
     $page = $this->repos->findOneBy(array('slug' => $slug));
     if (!$page) {
         return $collection;
     }
     $_page = $page->getParent();
     while (count($slugs)) {
         $_slug = array_pop($slugs);
         if (!$_page || $_slug !== $_page->getSlug()) {
             return $collection;
         }
         $_page = $_page->getParent();
     }
     if ($_page) {
         return $collection;
     }
     $template = $page->getPageTemplate();
     if (!$template) {
         $template = $this->template;
     }
     $defaults = array('_controller' => $this->controller, '_page_template' => $template, '_page_object' => $page);
     $requirements = array();
     $route = new Route($path, $defaults, $requirements);
     $name = 'sf_page_' . $page->getSlug();
     $collection->add($name, $route);
     return $collection;
 }
 function it_moves_down_item_when_move_down_action_called(CRUDElement $element, NestedTreeRepository $repository, \StdClass $category, ObjectManager $om, Router $router, DoctrineDataIndexer $indexer, Request $request)
 {
     $indexer->getData(1)->willReturn($category);
     $repository->moveDown($category)->shouldBeCalled();
     $om->flush()->shouldBeCalled();
     $router->generate('fsi_admin_crud_list', Argument::withEntry('element', 'category'))->willReturn('sample-path');
     $response = $this->moveDownAction($element, 1, $request);
     $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse');
     $response->getTargetUrl()->shouldReturn('sample-path');
 }
Exemplo n.º 3
0
 /**
  * @param Page[] $pages
  * @param ItemInterface $menu
  * @return ItemInterface
  */
 private function createNestedMenu(array $pages, ItemInterface $menu)
 {
     foreach ($pages as $page) {
         if ($page->getShowInMenu()) {
             $menuItem = $this->factory->createItem($page->getTitle(), ['route' => 'show_page', 'routeParameters' => ['slug' => $page->getSlug()]]);
             $children = $this->repository->getChildren($page, true);
             if (null !== $children) {
                 $this->createNestedMenu($children, $menuItem);
             }
             $menu->addChild($menuItem);
         }
     }
     return $menu;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function __construct(EntityManager $em, ClassMetadata $class)
 {
     parent::__construct($em, $class);
     if (isset($this->getClassMetadata()->associationMappings['translations']) && !empty($this->getClassMetadata()->associationMappings['translations'])) {
         $this->_entityTranslationName = $this->getClassMetadata()->associationMappings['translations']['targetEntity'];
     }
 }
Exemplo n.º 5
0
 /**
  * Use same instance of nodes during the requst
  *
  * @see parent::getRootNodes()
  * @return array
  */
 public function getRootNodes()
 {
     if (null === $this->nodes) {
         $this->nodes = parent::getRootNodes();
     }
     return $this->nodes;
 }
Exemplo n.º 6
0
 /**
  * Will do reordering based on current translations
  */
 public function childrenQuery($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $include = false)
 {
     $q = parent::childrenQuery($node, $direct, $sortByField, $direction, $include);
     if ($this->onChildrenQuery instanceof Closure) {
         $c =& $this->onChildrenQuery;
         $c($q);
     }
     return $q;
 }
Exemplo n.º 7
0
 public function __construct(EntityManager $em, ClassMetadata $class)
 {
     parent::__construct($em, $class);
     $this->em = $em;
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function getRootNodesQueryBuilder($sortByField = null, $direction = 'asc')
 {
     $qb = parent::getRootNodesQueryBuilder($sortByField, $direction);
     $qb->andWhere($qb->expr()->not($qb->expr()->eq('node.id', ':hiddenCollection')))->setParameter('hiddenCollection', CollectionEntity::TEMPORARY_UPLOAD_COLLECTION_ID);
     return $qb;
 }
 /**
  * {@inheritdoc}
  */
 public function getNodesHierarchyQueryBuilder($node = null, $direct = false, array $options = array(), $includeNode = false)
 {
     /** @var QueryBuilder $qb */
     $qb = parent::getNodesHierarchyQueryBuilder($node, $direct, $options, $includeNode);
     $qb->andWhere('node.deleted != true');
     return $qb;
 }
Exemplo n.º 10
0
 /**
  * @param EntityManager $em
  * @param \Doctrine\ORM\Mapping\ClassMetadata $class
  */
 public function __construct(EntityManager $em, $class)
 {
     $classMetaData = $em->getClassMetadata($class);
     parent::__construct($em, $classMetaData);
 }
Exemplo n.º 11
0
 private function rebuildSlugs(Page $page, NestedTreeRepository $repo, ObjectManager $em, $buildPages = false)
 {
     $pages = [];
     //$page->setSlug(null);
     //$em->persist($page);
     //$em->flush();
     if ($buildPages) {
         $pages[] = ['id' => $page->getId(), 'editUrl' => $this->generateUrl('page_update', ['slug' => $page->getSlug()])];
     }
     $childs = $repo->getChildren($page);
     foreach ($childs as $child) {
         $child->setSlug(null);
         $em->persist($child);
         $em->flush();
         if ($buildPages) {
             $pages[] = ['id' => $child->getId(), 'editUrl' => $this->generateUrl('page_update', ['slug' => $child->getSlug()])];
         }
     }
     return $pages;
 }
Exemplo n.º 12
0
 /**
  * Create a new QueryBuilder instance that is pre populated for this entity name
  *
  * @param   string $alias
  * @return  \Doctrine\ORM\QueryBuilder $qb
  * @access  protected
  */
 public function createQueryBuilder($alias)
 {
     $builder = parent::createQueryBuilder($alias);
     $builder->setAlias($alias);
     return $builder;
 }
 /**
  * {@inheritdoc}
  */
 public function persistAsFirstChildOf(CategoryInterface $node, CategoryInterface $parent)
 {
     parent::persistAsFirstChildOf($node, $parent);
     $this->_em->flush($node);
 }
Exemplo n.º 14
0
 /**
  * {@inheritDoc}
  */
 public function childrenQueryBuilder($node = NULL, $direct = FALSE, $sortByField = NULL, $direction = 'ASC', $includeNode = FALSE)
 {
     $qb = parent::childrenQueryBuilder($node, $direct, $sortByField, $direction, $includeNode);
     if ($this->onlyEnabled) {
         $qb->andWhere($qb->expr()->eq('node.isEnabled', 1));
     }
     return $qb;
 }
Exemplo n.º 15
0
 public function getChildrenQueryBuilderByAdministration(Administration $administration, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = true)
 {
     $root = $this->getRootByAdministration($administration);
     return parent::getChildrenQueryBuilder($root, $direct, $sortByField, $direction, $includeNode);
 }