예제 #1
0
 /**
  * @param Request $request
  * @return TagListHandler
  */
 public static function fromRequest(Request $request)
 {
     /** @var TagListHandler $listHandler */
     $listHandler = parent::fromRequest($request);
     $listHandler->setField($request->attributes->get('_field'));
     $listHandler->setTag($request->attributes->get('tag'));
     if (!$request->attributes->has('_list_template')) {
         $listHandler->setTemplate('GravityTagBundle:Node:list-by-tag.html.twig');
     }
     return $listHandler;
 }
예제 #2
0
 public function listAction(Request $request)
 {
     $listHandler = ListHandler::fromRequest($request);
     if (!$listHandler->getEntity()) {
         throw new BadRequestHttpException('You must specify the _entity key in the route defaults');
     }
     /** @var EntityManager $entityManager */
     $entityManager = $this->getDoctrine()->getManager();
     $queryBuilder = $entityManager->createQueryBuilder();
     $listHandler->buildQuery($queryBuilder);
     $paginator = new Paginator($queryBuilder);
     return $this->render($listHandler->getTemplate(), ['nodes' => $paginator, 'page_title' => $listHandler->getTitle()]);
 }