@@ 75-94 (lines=20) @@ | ||
72 | * |
|
73 | * @return CriteriaQueryBuilderInterface |
|
74 | */ |
|
75 | public function addFilter(FilterInterface $filter): CriteriaQueryBuilderInterface |
|
76 | { |
|
77 | $supports = false; |
|
78 | ||
79 | /** @var AbstractHandler $handler */ |
|
80 | foreach ($this->handlers->all() as $handler) { |
|
81 | if ($handler instanceof FilterHandlerInterface && $handler->supports($filter)) { |
|
82 | $supports = true; |
|
83 | $handler->addFilter($filter); |
|
84 | } |
|
85 | } |
|
86 | ||
87 | if (!$supports) { |
|
88 | throw new \RuntimeException('No available handler for this filter.'); |
|
89 | } |
|
90 | ||
91 | $this->resetApply(); |
|
92 | ||
93 | return $this; |
|
94 | } |
|
95 | ||
96 | protected function resetApply():void |
|
97 | { |
|
@@ 106-125 (lines=20) @@ | ||
103 | * |
|
104 | * @return CriteriaQueryBuilderInterface |
|
105 | */ |
|
106 | public function addSorting(SortInterface $sort): CriteriaQueryBuilderInterface |
|
107 | { |
|
108 | $supports = false; |
|
109 | ||
110 | /** @var AbstractHandler $handler */ |
|
111 | foreach ($this->handlers->all() as $handler) { |
|
112 | if ($handler instanceof SortHandlerInterface && $handler->supports($sort)) { |
|
113 | $supports = true; |
|
114 | $handler->addSorting($sort); |
|
115 | } |
|
116 | } |
|
117 | ||
118 | if (!$supports) { |
|
119 | throw new \RuntimeException('No available handler for this sorting.'); |
|
120 | } |
|
121 | ||
122 | $this->resetApply(); |
|
123 | ||
124 | return $this; |
|
125 | } |
|
126 | ||
127 | /** |
|
128 | * @return \Doctrine\ORM\QueryBuilder |