コード例 #1
0
 public function listRoutesAction(Request $request)
 {
     $repo = $this->get('wucdbm_menu_builder.repo.routes');
     $filter = new RouteFilter();
     $pagination = $filter->getPagination()->enable();
     $filterForm = $this->createForm(FilterType::class, $filter);
     $filter->load($request, $filterForm);
     $routes = $repo->filter($filter);
     $data = ['routes' => $routes, 'filter' => $filter, 'pagination' => $pagination, 'filterForm' => $filterForm->createView()];
     return $this->render('@WucdbmMenuBuilder/Route/list/list.html.twig', $data);
 }
コード例 #2
0
 public function filter(RouteFilter $filter)
 {
     $builder = $this->getQueryBuilder();
     if ($filter->getName()) {
         $builder->andWhere('r.name LIKE :name')->setParameter('name', '%' . $filter->getName() . '%');
     }
     if ($filter->getRoute()) {
         $builder->andWhere('r.route LIKE :route')->setParameter('route', '%' . $filter->getRoute() . '%');
     }
     if ($filter->getParameter()) {
         $builder->andWhere('p.parameter LIKE :parameter')->setParameter('parameter', '%' . $filter->getParameter() . '%');
     }
     if ($filter->getParameterName()) {
         $builder->andWhere('p.name LIKE :parameterName')->setParameter('parameterName', '%' . $filter->getParameterName() . '%');
     }
     if ($filter->getIsNamed()) {
         switch ($filter->getIsNamed()) {
             case RouteFilter::IS_NAMED_TRUE:
                 $builder->andWhere('r.name IS NOT NULL');
                 break;
             case RouteFilter::IS_NAMED_FALSE:
                 $builder->andWhere('r.name IS NULL');
                 break;
         }
     }
     if ($filter->getIsSystem()) {
         switch ($filter->getIsSystem()) {
             case RouteFilter::IS_SYSTEM_TRUE:
                 $builder->andWhere('r.isSystem = :isSystem')->setParameter('isSystem', true);
                 break;
             case RouteFilter::IS_SYSTEM_FALSE:
                 $builder->andWhere('r.isSystem = :isSystem')->setParameter('isSystem', false);
                 break;
         }
     }
     return $this->returnFilteredEntities($builder, $filter, 'r.id');
 }