Routing. How to remove the nesting levels?

there are references of the form
site.loc/catalog/ees/catalogGroup-31177
site.loc/catalog/bbs/catalogGroup-31232/catalogGroup-31
site.loc/catalog/bvs/catalogGroup-3232/catalogGrou...

here's the route for that page:

_auto:
 pattern: /{url}
 defaults: { _controller: SiteRsrSecurityBundle:ContentTypes:loadUrlPage }
requirements:
 url: ".+"


Here is a method of ContentTypesController

public function catalogGroupType(Page $page)
{
 $childGroups = $this->getContentService()->getListPages($page->getId(), new PageFilter('catalogGroup'));

 echo $page->getId();
 if ( /*count($this->data['navPath'][0]) and */ count($childGroups)) {
 $firstPage = current($childGroups);
 // echo count($this->data['navPath'][0]);
 return $this->redirect($this->convertUrl($firstPage->getUrl()));
}

 $this->data['groups'] = array();
 if (count($childGroups)) {
 $this->data['groups'] = $childGroups; 
 } else { 
 $parentPage = end($this->data['navPath'][0]);
 if ($parentPage) 
 $this->data['groups'] = $this->getContentService()->getListPages($parentPage->getId(), new PageFilter('catalogGroup'));
}


 $startPage = $this->getRequest()->get('page', 1);
 $idsChildGroup = array_keys($childGroups);


 //Third level
 if (count($idsChildGroup)) {

 $subChildGroups = $this->getContentService()->getListPages($idsChildGroup, new PageFilter('catalogGroup'));
 $idsChildGroup = array_merge($idsChildGroup, array_keys($subChildGroups));
}

 $idsGroup = array_merge(array($page->getId()), $idsChildGroup);

 try {
 $productsQuery = $this->getContentService()->getListPagesQuery($idsGroup, new PageFilter('product', 'p.price, p.title'));
 $this->data['products'] = $this->getPaginator()->paginate($productsQuery, $startPage, 15);
 } catch (\Exception $exc) {
 return $this->pageNotFound();
}

 return $this->renderPage('PageType:catalog_group.html.twig');
 }


as a reference to bring to mind:

site.loc/catalogGroup-31177
site.loc/catalogGroup-31232/catalogGroup-31
site.loc/catalogGroup-3232/catalogGroup-5789/item

Thanks in advance
September 19th 19 at 00:14
1 answer
September 19th 19 at 00:16
Tin kind.

Why not just use a Dynamic Router?

Find more questions by tags Symfony