Пример #1
0
 public function filterList(ListEvent $event)
 {
     $route = $event->getRouteName();
     $nonRestrictedRoutes = ['crud_controller.icons.list', 'crud_controller.articles.list', 'crud_controller.techs.list', 'crud_controller.projects.list'];
     if (in_array($route, $nonRestrictedRoutes) || !$this->user instanceof User) {
         return;
     }
     $queryBuilder = $event->getQueryBuilder();
     $aliases = $queryBuilder->getRootAliases();
     $alias = array_values($aliases)[0];
     $queryBuilder->andWhere($alias . '.user = :user')->setParameter('user', $this->user);
 }
Пример #2
0
 /**
  * @param string $routeName
  * @param mixed $query
  * @param Request $request
  */
 function __construct(string $routeName, $query, Request $request)
 {
     parent::__construct($routeName, $query, $request);
     if ($query instanceof QueryBuilder) {
         $this->results = $query->getQuery()->getResult();
     } elseif ($query instanceof \ModelCriteria) {
         $results = $query->find();
         if ($results instanceof \PropelObjectCollection) {
             $this->results = $results->toArray();
         }
     } elseif ($query instanceof Query) {
         $this->results = [];
     }
 }
Пример #3
0
 /**
  * @param string $routeName
  * @param mixed $query
  * @param Request $request
  * @param FormInterface $form
  * @param string|null $alias
  */
 function __construct(string $routeName, $query, Request $request, FormInterface $form, string $alias = null)
 {
     parent::__construct($routeName, $query, $request);
     $this->form = $form;
     $this->alias = $alias;
 }