@@ -273,7 +273,7 @@ |
||
273 | 273 | { |
274 | 274 | $this->sut = new Uploader($this->filesystemMock); |
275 | 275 | |
276 | - $fooPathFactory = fn ($filename) => "/foo-base-dir/$filename"; |
|
276 | + $fooPathFactory = fn($filename) => "/foo-base-dir/$filename"; |
|
277 | 277 | |
278 | 278 | $key = 'foo'; |
279 | 279 | $path = 'example.foo'; |
@@ -39,162 +39,3 @@ |
||
39 | 39 | * %2$s - nodes (filters) |
40 | 40 | */ |
41 | 41 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
42 | - <div class="hidable"> |
|
43 | - <p class="hider">%1$s</p> |
|
44 | - <div class="hidee">%2$s</div> |
|
45 | - </div> |
|
46 | - EOT; |
|
47 | - |
|
48 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
49 | - |
|
50 | - /** @var IFilter[] */ |
|
51 | - protected array $nodes = []; |
|
52 | - |
|
53 | - protected string $nodeClass = IFilter::class; |
|
54 | - |
|
55 | - protected Action $hiderBtn; |
|
56 | - |
|
57 | - protected Action $filterBtn; |
|
58 | - |
|
59 | - protected Action $resetBtn; |
|
60 | - |
|
61 | - /** |
|
62 | - * Filters constructor. |
|
63 | - * |
|
64 | - * @param string[] $intents |
|
65 | - * @param Attributes|null $attributes |
|
66 | - * @param string|null $tag |
|
67 | - */ |
|
68 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
69 | - { |
|
70 | - parent::__construct(null, $intents, $attributes, $tag); |
|
71 | - |
|
72 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
73 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
74 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param array $params |
|
79 | - * |
|
80 | - * @return $this |
|
81 | - */ |
|
82 | - public function setParams(array $params): Filters |
|
83 | - { |
|
84 | - foreach ($this->nodes as $filter) { |
|
85 | - $filter->setParams($params); |
|
86 | - } |
|
87 | - |
|
88 | - return $this; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $baseUrl |
|
93 | - * |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function getUrl(string $baseUrl): string |
|
97 | - { |
|
98 | - $queryParts = []; |
|
99 | - foreach ($this->nodes as $filter) { |
|
100 | - $queryPart = $filter->getQueryPart(); |
|
101 | - if (!$queryPart) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - |
|
105 | - $queryParts[] = $queryPart; |
|
106 | - } |
|
107 | - |
|
108 | - if (empty($queryParts)) { |
|
109 | - return $baseUrl; |
|
110 | - } |
|
111 | - |
|
112 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function getWhereConditions(): array |
|
119 | - { |
|
120 | - $conditions = []; |
|
121 | - foreach ($this->nodes as $filter) { |
|
122 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
123 | - } |
|
124 | - |
|
125 | - return $conditions; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return array<string,string> |
|
130 | - */ |
|
131 | - public function getSqlParams(): array |
|
132 | - { |
|
133 | - $params = []; |
|
134 | - foreach ($this->nodes as $filter) { |
|
135 | - $params = array_merge($params, $filter->getQueryParams()); |
|
136 | - } |
|
137 | - |
|
138 | - return $params; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @return INode[] |
|
143 | - */ |
|
144 | - public function getExtendedNodes(): array |
|
145 | - { |
|
146 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @param string $template |
|
151 | - * |
|
152 | - * @return INode |
|
153 | - */ |
|
154 | - public function setTemplate(string $template): INode |
|
155 | - { |
|
156 | - $this->template = $template; |
|
157 | - |
|
158 | - return $this; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function __toString(): string |
|
165 | - { |
|
166 | - $nodes = Collection::__toString(); |
|
167 | - |
|
168 | - $form = sprintf(self::WITH_CONTENT_TAG, $this->tag, $nodes, new Attributes( [Html5::ATTR_CLASS => 'filter-form'])); |
|
169 | - |
|
170 | - return sprintf( |
|
171 | - $this->template, |
|
172 | - (string)$this->hiderBtn, |
|
173 | - $form |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return Action |
|
179 | - */ |
|
180 | - public function getHiderBtn(): Action |
|
181 | - { |
|
182 | - return $this->hiderBtn; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @return Action |
|
187 | - */ |
|
188 | - public function getFilterBtn(): Action |
|
189 | - { |
|
190 | - return $this->filterBtn; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @return Action |
|
195 | - */ |
|
196 | - public function getResetBtn(): Action |
|
197 | - { |
|
198 | - return $this->resetBtn; |
|
199 | - } |
|
200 | -} |
@@ -39,162 +39,3 @@ |
||
39 | 39 | * %2$s - nodes (filters) |
40 | 40 | */ |
41 | 41 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
42 | - <div class="hidable"> |
|
43 | - <p class="hider">%1$s</p> |
|
44 | - <div class="hidee">%2$s</div> |
|
45 | - </div> |
|
46 | - EOT; |
|
47 | - |
|
48 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
49 | - |
|
50 | - /** @var IFilter[] */ |
|
51 | - protected array $nodes = []; |
|
52 | - |
|
53 | - protected string $nodeClass = IFilter::class; |
|
54 | - |
|
55 | - protected Action $hiderBtn; |
|
56 | - |
|
57 | - protected Action $filterBtn; |
|
58 | - |
|
59 | - protected Action $resetBtn; |
|
60 | - |
|
61 | - /** |
|
62 | - * Filters constructor. |
|
63 | - * |
|
64 | - * @param string[] $intents |
|
65 | - * @param Attributes|null $attributes |
|
66 | - * @param string|null $tag |
|
67 | - */ |
|
68 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
69 | - { |
|
70 | - parent::__construct(null, $intents, $attributes, $tag); |
|
71 | - |
|
72 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
73 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
74 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param array $params |
|
79 | - * |
|
80 | - * @return $this |
|
81 | - */ |
|
82 | - public function setParams(array $params): Filters |
|
83 | - { |
|
84 | - foreach ($this->nodes as $filter) { |
|
85 | - $filter->setParams($params); |
|
86 | - } |
|
87 | - |
|
88 | - return $this; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $baseUrl |
|
93 | - * |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function getUrl(string $baseUrl): string |
|
97 | - { |
|
98 | - $queryParts = []; |
|
99 | - foreach ($this->nodes as $filter) { |
|
100 | - $queryPart = $filter->getQueryPart(); |
|
101 | - if (!$queryPart) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - |
|
105 | - $queryParts[] = $queryPart; |
|
106 | - } |
|
107 | - |
|
108 | - if (empty($queryParts)) { |
|
109 | - return $baseUrl; |
|
110 | - } |
|
111 | - |
|
112 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function getWhereConditions(): array |
|
119 | - { |
|
120 | - $conditions = []; |
|
121 | - foreach ($this->nodes as $filter) { |
|
122 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
123 | - } |
|
124 | - |
|
125 | - return $conditions; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return array<string,string> |
|
130 | - */ |
|
131 | - public function getSqlParams(): array |
|
132 | - { |
|
133 | - $params = []; |
|
134 | - foreach ($this->nodes as $filter) { |
|
135 | - $params = array_merge($params, $filter->getQueryParams()); |
|
136 | - } |
|
137 | - |
|
138 | - return $params; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @return INode[] |
|
143 | - */ |
|
144 | - public function getExtendedNodes(): array |
|
145 | - { |
|
146 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @param string $template |
|
151 | - * |
|
152 | - * @return INode |
|
153 | - */ |
|
154 | - public function setTemplate(string $template): INode |
|
155 | - { |
|
156 | - $this->template = $template; |
|
157 | - |
|
158 | - return $this; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function __toString(): string |
|
165 | - { |
|
166 | - $nodes = Collection::__toString(); |
|
167 | - |
|
168 | - $form = sprintf(self::WITH_CONTENT_TAG, $this->tag, $nodes, new Attributes( [Html5::ATTR_CLASS => 'filter-form'])); |
|
169 | - |
|
170 | - return sprintf( |
|
171 | - $this->template, |
|
172 | - (string)$this->hiderBtn, |
|
173 | - $form |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return Action |
|
179 | - */ |
|
180 | - public function getHiderBtn(): Action |
|
181 | - { |
|
182 | - return $this->hiderBtn; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @return Action |
|
187 | - */ |
|
188 | - public function getFilterBtn(): Action |
|
189 | - { |
|
190 | - return $this->filterBtn; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @return Action |
|
195 | - */ |
|
196 | - public function getResetBtn(): Action |
|
197 | - { |
|
198 | - return $this->resetBtn; |
|
199 | - } |
|
200 | -} |
@@ -39,162 +39,3 @@ |
||
39 | 39 | * %2$s - nodes (filters) |
40 | 40 | */ |
41 | 41 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
42 | - <div class="hidable"> |
|
43 | - <p class="hider">%1$s</p> |
|
44 | - <div class="hidee">%2$s</div> |
|
45 | - </div> |
|
46 | - EOT; |
|
47 | - |
|
48 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
49 | - |
|
50 | - /** @var IFilter[] */ |
|
51 | - protected array $nodes = []; |
|
52 | - |
|
53 | - protected string $nodeClass = IFilter::class; |
|
54 | - |
|
55 | - protected Action $hiderBtn; |
|
56 | - |
|
57 | - protected Action $filterBtn; |
|
58 | - |
|
59 | - protected Action $resetBtn; |
|
60 | - |
|
61 | - /** |
|
62 | - * Filters constructor. |
|
63 | - * |
|
64 | - * @param string[] $intents |
|
65 | - * @param Attributes|null $attributes |
|
66 | - * @param string|null $tag |
|
67 | - */ |
|
68 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
69 | - { |
|
70 | - parent::__construct(null, $intents, $attributes, $tag); |
|
71 | - |
|
72 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
73 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
74 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param array $params |
|
79 | - * |
|
80 | - * @return $this |
|
81 | - */ |
|
82 | - public function setParams(array $params): Filters |
|
83 | - { |
|
84 | - foreach ($this->nodes as $filter) { |
|
85 | - $filter->setParams($params); |
|
86 | - } |
|
87 | - |
|
88 | - return $this; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $baseUrl |
|
93 | - * |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function getUrl(string $baseUrl): string |
|
97 | - { |
|
98 | - $queryParts = []; |
|
99 | - foreach ($this->nodes as $filter) { |
|
100 | - $queryPart = $filter->getQueryPart(); |
|
101 | - if (!$queryPart) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - |
|
105 | - $queryParts[] = $queryPart; |
|
106 | - } |
|
107 | - |
|
108 | - if (empty($queryParts)) { |
|
109 | - return $baseUrl; |
|
110 | - } |
|
111 | - |
|
112 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function getWhereConditions(): array |
|
119 | - { |
|
120 | - $conditions = []; |
|
121 | - foreach ($this->nodes as $filter) { |
|
122 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
123 | - } |
|
124 | - |
|
125 | - return $conditions; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return array<string,string> |
|
130 | - */ |
|
131 | - public function getSqlParams(): array |
|
132 | - { |
|
133 | - $params = []; |
|
134 | - foreach ($this->nodes as $filter) { |
|
135 | - $params = array_merge($params, $filter->getQueryParams()); |
|
136 | - } |
|
137 | - |
|
138 | - return $params; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @return INode[] |
|
143 | - */ |
|
144 | - public function getExtendedNodes(): array |
|
145 | - { |
|
146 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @param string $template |
|
151 | - * |
|
152 | - * @return INode |
|
153 | - */ |
|
154 | - public function setTemplate(string $template): INode |
|
155 | - { |
|
156 | - $this->template = $template; |
|
157 | - |
|
158 | - return $this; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function __toString(): string |
|
165 | - { |
|
166 | - $nodes = Collection::__toString(); |
|
167 | - |
|
168 | - $form = sprintf(self::WITH_CONTENT_TAG, $this->tag, $nodes, new Attributes( [Html5::ATTR_CLASS => 'filter-form'])); |
|
169 | - |
|
170 | - return sprintf( |
|
171 | - $this->template, |
|
172 | - (string)$this->hiderBtn, |
|
173 | - $form |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return Action |
|
179 | - */ |
|
180 | - public function getHiderBtn(): Action |
|
181 | - { |
|
182 | - return $this->hiderBtn; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @return Action |
|
187 | - */ |
|
188 | - public function getFilterBtn(): Action |
|
189 | - { |
|
190 | - return $this->filterBtn; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @return Action |
|
195 | - */ |
|
196 | - public function getResetBtn(): Action |
|
197 | - { |
|
198 | - return $this->resetBtn; |
|
199 | - } |
|
200 | -} |
@@ -39,162 +39,3 @@ |
||
39 | 39 | * %2$s - nodes (filters) |
40 | 40 | */ |
41 | 41 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
42 | - <div class="hidable"> |
|
43 | - <p class="hider">%1$s</p> |
|
44 | - <div class="hidee">%2$s</div> |
|
45 | - </div> |
|
46 | - EOT; |
|
47 | - |
|
48 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
49 | - |
|
50 | - /** @var IFilter[] */ |
|
51 | - protected array $nodes = []; |
|
52 | - |
|
53 | - protected string $nodeClass = IFilter::class; |
|
54 | - |
|
55 | - protected Action $hiderBtn; |
|
56 | - |
|
57 | - protected Action $filterBtn; |
|
58 | - |
|
59 | - protected Action $resetBtn; |
|
60 | - |
|
61 | - /** |
|
62 | - * Filters constructor. |
|
63 | - * |
|
64 | - * @param string[] $intents |
|
65 | - * @param Attributes|null $attributes |
|
66 | - * @param string|null $tag |
|
67 | - */ |
|
68 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
69 | - { |
|
70 | - parent::__construct(null, $intents, $attributes, $tag); |
|
71 | - |
|
72 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
73 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
74 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param array $params |
|
79 | - * |
|
80 | - * @return $this |
|
81 | - */ |
|
82 | - public function setParams(array $params): Filters |
|
83 | - { |
|
84 | - foreach ($this->nodes as $filter) { |
|
85 | - $filter->setParams($params); |
|
86 | - } |
|
87 | - |
|
88 | - return $this; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $baseUrl |
|
93 | - * |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function getUrl(string $baseUrl): string |
|
97 | - { |
|
98 | - $queryParts = []; |
|
99 | - foreach ($this->nodes as $filter) { |
|
100 | - $queryPart = $filter->getQueryPart(); |
|
101 | - if (!$queryPart) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - |
|
105 | - $queryParts[] = $queryPart; |
|
106 | - } |
|
107 | - |
|
108 | - if (empty($queryParts)) { |
|
109 | - return $baseUrl; |
|
110 | - } |
|
111 | - |
|
112 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function getWhereConditions(): array |
|
119 | - { |
|
120 | - $conditions = []; |
|
121 | - foreach ($this->nodes as $filter) { |
|
122 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
123 | - } |
|
124 | - |
|
125 | - return $conditions; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return array<string,string> |
|
130 | - */ |
|
131 | - public function getSqlParams(): array |
|
132 | - { |
|
133 | - $params = []; |
|
134 | - foreach ($this->nodes as $filter) { |
|
135 | - $params = array_merge($params, $filter->getQueryParams()); |
|
136 | - } |
|
137 | - |
|
138 | - return $params; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @return INode[] |
|
143 | - */ |
|
144 | - public function getExtendedNodes(): array |
|
145 | - { |
|
146 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @param string $template |
|
151 | - * |
|
152 | - * @return INode |
|
153 | - */ |
|
154 | - public function setTemplate(string $template): INode |
|
155 | - { |
|
156 | - $this->template = $template; |
|
157 | - |
|
158 | - return $this; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function __toString(): string |
|
165 | - { |
|
166 | - $nodes = Collection::__toString(); |
|
167 | - |
|
168 | - $form = sprintf(self::WITH_CONTENT_TAG, $this->tag, $nodes, new Attributes( [Html5::ATTR_CLASS => 'filter-form'])); |
|
169 | - |
|
170 | - return sprintf( |
|
171 | - $this->template, |
|
172 | - (string)$this->hiderBtn, |
|
173 | - $form |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return Action |
|
179 | - */ |
|
180 | - public function getHiderBtn(): Action |
|
181 | - { |
|
182 | - return $this->hiderBtn; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @return Action |
|
187 | - */ |
|
188 | - public function getFilterBtn(): Action |
|
189 | - { |
|
190 | - return $this->filterBtn; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @return Action |
|
195 | - */ |
|
196 | - public function getResetBtn(): Action |
|
197 | - { |
|
198 | - return $this->resetBtn; |
|
199 | - } |
|
200 | -} |
@@ -39,162 +39,3 @@ |
||
39 | 39 | * %2$s - nodes (filters) |
40 | 40 | */ |
41 | 41 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
42 | - <div class="hidable"> |
|
43 | - <p class="hider">%1$s</p> |
|
44 | - <div class="hidee">%2$s</div> |
|
45 | - </div> |
|
46 | - EOT; |
|
47 | - |
|
48 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
49 | - |
|
50 | - /** @var IFilter[] */ |
|
51 | - protected array $nodes = []; |
|
52 | - |
|
53 | - protected string $nodeClass = IFilter::class; |
|
54 | - |
|
55 | - protected Action $hiderBtn; |
|
56 | - |
|
57 | - protected Action $filterBtn; |
|
58 | - |
|
59 | - protected Action $resetBtn; |
|
60 | - |
|
61 | - /** |
|
62 | - * Filters constructor. |
|
63 | - * |
|
64 | - * @param string[] $intents |
|
65 | - * @param Attributes|null $attributes |
|
66 | - * @param string|null $tag |
|
67 | - */ |
|
68 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
69 | - { |
|
70 | - parent::__construct(null, $intents, $attributes, $tag); |
|
71 | - |
|
72 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
73 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
74 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param array $params |
|
79 | - * |
|
80 | - * @return $this |
|
81 | - */ |
|
82 | - public function setParams(array $params): Filters |
|
83 | - { |
|
84 | - foreach ($this->nodes as $filter) { |
|
85 | - $filter->setParams($params); |
|
86 | - } |
|
87 | - |
|
88 | - return $this; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $baseUrl |
|
93 | - * |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function getUrl(string $baseUrl): string |
|
97 | - { |
|
98 | - $queryParts = []; |
|
99 | - foreach ($this->nodes as $filter) { |
|
100 | - $queryPart = $filter->getQueryPart(); |
|
101 | - if (!$queryPart) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - |
|
105 | - $queryParts[] = $queryPart; |
|
106 | - } |
|
107 | - |
|
108 | - if (empty($queryParts)) { |
|
109 | - return $baseUrl; |
|
110 | - } |
|
111 | - |
|
112 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function getWhereConditions(): array |
|
119 | - { |
|
120 | - $conditions = []; |
|
121 | - foreach ($this->nodes as $filter) { |
|
122 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
123 | - } |
|
124 | - |
|
125 | - return $conditions; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return array<string,string> |
|
130 | - */ |
|
131 | - public function getSqlParams(): array |
|
132 | - { |
|
133 | - $params = []; |
|
134 | - foreach ($this->nodes as $filter) { |
|
135 | - $params = array_merge($params, $filter->getQueryParams()); |
|
136 | - } |
|
137 | - |
|
138 | - return $params; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @return INode[] |
|
143 | - */ |
|
144 | - public function getExtendedNodes(): array |
|
145 | - { |
|
146 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @param string $template |
|
151 | - * |
|
152 | - * @return INode |
|
153 | - */ |
|
154 | - public function setTemplate(string $template): INode |
|
155 | - { |
|
156 | - $this->template = $template; |
|
157 | - |
|
158 | - return $this; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function __toString(): string |
|
165 | - { |
|
166 | - $nodes = Collection::__toString(); |
|
167 | - |
|
168 | - $form = sprintf(self::WITH_CONTENT_TAG, $this->tag, $nodes, new Attributes( [Html5::ATTR_CLASS => 'filter-form'])); |
|
169 | - |
|
170 | - return sprintf( |
|
171 | - $this->template, |
|
172 | - (string)$this->hiderBtn, |
|
173 | - $form |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return Action |
|
179 | - */ |
|
180 | - public function getHiderBtn(): Action |
|
181 | - { |
|
182 | - return $this->hiderBtn; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @return Action |
|
187 | - */ |
|
188 | - public function getFilterBtn(): Action |
|
189 | - { |
|
190 | - return $this->filterBtn; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @return Action |
|
195 | - */ |
|
196 | - public function getResetBtn(): Action |
|
197 | - { |
|
198 | - return $this->resetBtn; |
|
199 | - } |
|
200 | -} |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | public function testUnsetAttributeValueWorksIfAttributeIsNotSet(): void |
81 | 81 | { |
82 | - $key = 'foo'; |
|
82 | + $key = 'foo'; |
|
83 | 83 | |
84 | 84 | $sut = $this->createNode(); |
85 | 85 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | public function testUnsetAttributeValueWorksIfAttributeIsSetButValueIsNot(): void |
112 | 112 | { |
113 | - $key = 'foo'; |
|
113 | + $key = 'foo'; |
|
114 | 114 | $value1 = 'bar'; |
115 | 115 | $value2 = 'baz'; |
116 | 116 |