@@ -38,166 +38,3 @@ |
||
| 38 | 38 | * %2$s - nodes (filters) |
| 39 | 39 | */ |
| 40 | 40 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 41 | - <div class="hidable"> |
|
| 42 | - <p class="hider">%1$s</p> |
|
| 43 | - <div class="hidee">%2$s</div> |
|
| 44 | - </div> |
|
| 45 | - EOT; |
|
| 46 | - |
|
| 47 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 48 | - |
|
| 49 | - /** @var IFilter[] */ |
|
| 50 | - protected array $nodes = []; |
|
| 51 | - |
|
| 52 | - protected string $nodeClass = IFilter::class; |
|
| 53 | - |
|
| 54 | - protected Action $hiderBtn; |
|
| 55 | - |
|
| 56 | - protected Action $filterBtn; |
|
| 57 | - |
|
| 58 | - protected Action $resetBtn; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Filters constructor. |
|
| 62 | - * |
|
| 63 | - * @param string[] $intents |
|
| 64 | - * @param array $attributes |
|
| 65 | - * @param string|null $tag |
|
| 66 | - */ |
|
| 67 | - public function __construct(array $intents = [], array $attributes = [], ?string $tag = null) |
|
| 68 | - { |
|
| 69 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 70 | - |
|
| 71 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 72 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
| 73 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param array $params |
|
| 78 | - * |
|
| 79 | - * @return $this |
|
| 80 | - */ |
|
| 81 | - public function setParams(array $params): Filters |
|
| 82 | - { |
|
| 83 | - foreach ($this->nodes as $filter) { |
|
| 84 | - $filter->setParams($params); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param string $baseUrl |
|
| 92 | - * |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function getUrl(string $baseUrl): string |
|
| 96 | - { |
|
| 97 | - $queryParts = []; |
|
| 98 | - foreach ($this->nodes as $filter) { |
|
| 99 | - $queryPart = $filter->getQueryPart(); |
|
| 100 | - if (!$queryPart) { |
|
| 101 | - continue; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $queryParts[] = $queryPart; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if (empty($queryParts)) { |
|
| 108 | - return $baseUrl; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @return array |
|
| 116 | - */ |
|
| 117 | - public function getWhereConditions(): array |
|
| 118 | - { |
|
| 119 | - $conditions = []; |
|
| 120 | - foreach ($this->nodes as $filter) { |
|
| 121 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $conditions; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public function getSqlParams(): array |
|
| 131 | - { |
|
| 132 | - $params = []; |
|
| 133 | - foreach ($this->nodes as $filter) { |
|
| 134 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $params; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return INode[] |
|
| 142 | - */ |
|
| 143 | - public function getExtendedNodes(): array |
|
| 144 | - { |
|
| 145 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param string $template |
|
| 150 | - * |
|
| 151 | - * @return INode |
|
| 152 | - */ |
|
| 153 | - public function setTemplate(string $template): INode |
|
| 154 | - { |
|
| 155 | - $this->template = $template; |
|
| 156 | - |
|
| 157 | - return $this; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return string |
|
| 162 | - */ |
|
| 163 | - public function __toString(): string |
|
| 164 | - { |
|
| 165 | - $nodes = Collection::__toString(); |
|
| 166 | - |
|
| 167 | - $form = StringHelper::wrapInTag( |
|
| 168 | - $nodes, |
|
| 169 | - $this->tag, |
|
| 170 | - static::ATTRIBUTES_FORM |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return sprintf( |
|
| 174 | - $this->template, |
|
| 175 | - (string)$this->hiderBtn, |
|
| 176 | - $form |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @return Action |
|
| 182 | - */ |
|
| 183 | - public function getHiderBtn(): Action |
|
| 184 | - { |
|
| 185 | - return $this->hiderBtn; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @return Action |
|
| 190 | - */ |
|
| 191 | - public function getFilterBtn(): Action |
|
| 192 | - { |
|
| 193 | - return $this->filterBtn; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @return Action |
|
| 198 | - */ |
|
| 199 | - public function getResetBtn(): Action |
|
| 200 | - { |
|
| 201 | - return $this->resetBtn; |
|
| 202 | - } |
|
| 203 | -} |
|
@@ -38,166 +38,3 @@ |
||
| 38 | 38 | * %2$s - nodes (filters) |
| 39 | 39 | */ |
| 40 | 40 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 41 | - <div class="hidable"> |
|
| 42 | - <p class="hider">%1$s</p> |
|
| 43 | - <div class="hidee">%2$s</div> |
|
| 44 | - </div> |
|
| 45 | - EOT; |
|
| 46 | - |
|
| 47 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 48 | - |
|
| 49 | - /** @var IFilter[] */ |
|
| 50 | - protected array $nodes = []; |
|
| 51 | - |
|
| 52 | - protected string $nodeClass = IFilter::class; |
|
| 53 | - |
|
| 54 | - protected Action $hiderBtn; |
|
| 55 | - |
|
| 56 | - protected Action $filterBtn; |
|
| 57 | - |
|
| 58 | - protected Action $resetBtn; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Filters constructor. |
|
| 62 | - * |
|
| 63 | - * @param string[] $intents |
|
| 64 | - * @param array $attributes |
|
| 65 | - * @param string|null $tag |
|
| 66 | - */ |
|
| 67 | - public function __construct(array $intents = [], array $attributes = [], ?string $tag = null) |
|
| 68 | - { |
|
| 69 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 70 | - |
|
| 71 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 72 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
| 73 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param array $params |
|
| 78 | - * |
|
| 79 | - * @return $this |
|
| 80 | - */ |
|
| 81 | - public function setParams(array $params): Filters |
|
| 82 | - { |
|
| 83 | - foreach ($this->nodes as $filter) { |
|
| 84 | - $filter->setParams($params); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param string $baseUrl |
|
| 92 | - * |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function getUrl(string $baseUrl): string |
|
| 96 | - { |
|
| 97 | - $queryParts = []; |
|
| 98 | - foreach ($this->nodes as $filter) { |
|
| 99 | - $queryPart = $filter->getQueryPart(); |
|
| 100 | - if (!$queryPart) { |
|
| 101 | - continue; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $queryParts[] = $queryPart; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if (empty($queryParts)) { |
|
| 108 | - return $baseUrl; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @return array |
|
| 116 | - */ |
|
| 117 | - public function getWhereConditions(): array |
|
| 118 | - { |
|
| 119 | - $conditions = []; |
|
| 120 | - foreach ($this->nodes as $filter) { |
|
| 121 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $conditions; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public function getSqlParams(): array |
|
| 131 | - { |
|
| 132 | - $params = []; |
|
| 133 | - foreach ($this->nodes as $filter) { |
|
| 134 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $params; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return INode[] |
|
| 142 | - */ |
|
| 143 | - public function getExtendedNodes(): array |
|
| 144 | - { |
|
| 145 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param string $template |
|
| 150 | - * |
|
| 151 | - * @return INode |
|
| 152 | - */ |
|
| 153 | - public function setTemplate(string $template): INode |
|
| 154 | - { |
|
| 155 | - $this->template = $template; |
|
| 156 | - |
|
| 157 | - return $this; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return string |
|
| 162 | - */ |
|
| 163 | - public function __toString(): string |
|
| 164 | - { |
|
| 165 | - $nodes = Collection::__toString(); |
|
| 166 | - |
|
| 167 | - $form = StringHelper::wrapInTag( |
|
| 168 | - $nodes, |
|
| 169 | - $this->tag, |
|
| 170 | - static::ATTRIBUTES_FORM |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return sprintf( |
|
| 174 | - $this->template, |
|
| 175 | - (string)$this->hiderBtn, |
|
| 176 | - $form |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @return Action |
|
| 182 | - */ |
|
| 183 | - public function getHiderBtn(): Action |
|
| 184 | - { |
|
| 185 | - return $this->hiderBtn; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @return Action |
|
| 190 | - */ |
|
| 191 | - public function getFilterBtn(): Action |
|
| 192 | - { |
|
| 193 | - return $this->filterBtn; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @return Action |
|
| 198 | - */ |
|
| 199 | - public function getResetBtn(): Action |
|
| 200 | - { |
|
| 201 | - return $this->resetBtn; |
|
| 202 | - } |
|
| 203 | -} |
|
@@ -38,166 +38,3 @@ |
||
| 38 | 38 | * %2$s - nodes (filters) |
| 39 | 39 | */ |
| 40 | 40 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 41 | - <div class="hidable"> |
|
| 42 | - <p class="hider">%1$s</p> |
|
| 43 | - <div class="hidee">%2$s</div> |
|
| 44 | - </div> |
|
| 45 | - EOT; |
|
| 46 | - |
|
| 47 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 48 | - |
|
| 49 | - /** @var IFilter[] */ |
|
| 50 | - protected array $nodes = []; |
|
| 51 | - |
|
| 52 | - protected string $nodeClass = IFilter::class; |
|
| 53 | - |
|
| 54 | - protected Action $hiderBtn; |
|
| 55 | - |
|
| 56 | - protected Action $filterBtn; |
|
| 57 | - |
|
| 58 | - protected Action $resetBtn; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Filters constructor. |
|
| 62 | - * |
|
| 63 | - * @param string[] $intents |
|
| 64 | - * @param array $attributes |
|
| 65 | - * @param string|null $tag |
|
| 66 | - */ |
|
| 67 | - public function __construct(array $intents = [], array $attributes = [], ?string $tag = null) |
|
| 68 | - { |
|
| 69 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 70 | - |
|
| 71 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 72 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
| 73 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param array $params |
|
| 78 | - * |
|
| 79 | - * @return $this |
|
| 80 | - */ |
|
| 81 | - public function setParams(array $params): Filters |
|
| 82 | - { |
|
| 83 | - foreach ($this->nodes as $filter) { |
|
| 84 | - $filter->setParams($params); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param string $baseUrl |
|
| 92 | - * |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function getUrl(string $baseUrl): string |
|
| 96 | - { |
|
| 97 | - $queryParts = []; |
|
| 98 | - foreach ($this->nodes as $filter) { |
|
| 99 | - $queryPart = $filter->getQueryPart(); |
|
| 100 | - if (!$queryPart) { |
|
| 101 | - continue; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $queryParts[] = $queryPart; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if (empty($queryParts)) { |
|
| 108 | - return $baseUrl; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @return array |
|
| 116 | - */ |
|
| 117 | - public function getWhereConditions(): array |
|
| 118 | - { |
|
| 119 | - $conditions = []; |
|
| 120 | - foreach ($this->nodes as $filter) { |
|
| 121 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $conditions; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public function getSqlParams(): array |
|
| 131 | - { |
|
| 132 | - $params = []; |
|
| 133 | - foreach ($this->nodes as $filter) { |
|
| 134 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $params; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return INode[] |
|
| 142 | - */ |
|
| 143 | - public function getExtendedNodes(): array |
|
| 144 | - { |
|
| 145 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param string $template |
|
| 150 | - * |
|
| 151 | - * @return INode |
|
| 152 | - */ |
|
| 153 | - public function setTemplate(string $template): INode |
|
| 154 | - { |
|
| 155 | - $this->template = $template; |
|
| 156 | - |
|
| 157 | - return $this; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return string |
|
| 162 | - */ |
|
| 163 | - public function __toString(): string |
|
| 164 | - { |
|
| 165 | - $nodes = Collection::__toString(); |
|
| 166 | - |
|
| 167 | - $form = StringHelper::wrapInTag( |
|
| 168 | - $nodes, |
|
| 169 | - $this->tag, |
|
| 170 | - static::ATTRIBUTES_FORM |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return sprintf( |
|
| 174 | - $this->template, |
|
| 175 | - (string)$this->hiderBtn, |
|
| 176 | - $form |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @return Action |
|
| 182 | - */ |
|
| 183 | - public function getHiderBtn(): Action |
|
| 184 | - { |
|
| 185 | - return $this->hiderBtn; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @return Action |
|
| 190 | - */ |
|
| 191 | - public function getFilterBtn(): Action |
|
| 192 | - { |
|
| 193 | - return $this->filterBtn; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @return Action |
|
| 198 | - */ |
|
| 199 | - public function getResetBtn(): Action |
|
| 200 | - { |
|
| 201 | - return $this->resetBtn; |
|
| 202 | - } |
|
| 203 | -} |
|
@@ -38,166 +38,3 @@ |
||
| 38 | 38 | * %2$s - nodes (filters) |
| 39 | 39 | */ |
| 40 | 40 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 41 | - <div class="hidable"> |
|
| 42 | - <p class="hider">%1$s</p> |
|
| 43 | - <div class="hidee">%2$s</div> |
|
| 44 | - </div> |
|
| 45 | - EOT; |
|
| 46 | - |
|
| 47 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 48 | - |
|
| 49 | - /** @var IFilter[] */ |
|
| 50 | - protected array $nodes = []; |
|
| 51 | - |
|
| 52 | - protected string $nodeClass = IFilter::class; |
|
| 53 | - |
|
| 54 | - protected Action $hiderBtn; |
|
| 55 | - |
|
| 56 | - protected Action $filterBtn; |
|
| 57 | - |
|
| 58 | - protected Action $resetBtn; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Filters constructor. |
|
| 62 | - * |
|
| 63 | - * @param string[] $intents |
|
| 64 | - * @param array $attributes |
|
| 65 | - * @param string|null $tag |
|
| 66 | - */ |
|
| 67 | - public function __construct(array $intents = [], array $attributes = [], ?string $tag = null) |
|
| 68 | - { |
|
| 69 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 70 | - |
|
| 71 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 72 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
| 73 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param array $params |
|
| 78 | - * |
|
| 79 | - * @return $this |
|
| 80 | - */ |
|
| 81 | - public function setParams(array $params): Filters |
|
| 82 | - { |
|
| 83 | - foreach ($this->nodes as $filter) { |
|
| 84 | - $filter->setParams($params); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param string $baseUrl |
|
| 92 | - * |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function getUrl(string $baseUrl): string |
|
| 96 | - { |
|
| 97 | - $queryParts = []; |
|
| 98 | - foreach ($this->nodes as $filter) { |
|
| 99 | - $queryPart = $filter->getQueryPart(); |
|
| 100 | - if (!$queryPart) { |
|
| 101 | - continue; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $queryParts[] = $queryPart; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if (empty($queryParts)) { |
|
| 108 | - return $baseUrl; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @return array |
|
| 116 | - */ |
|
| 117 | - public function getWhereConditions(): array |
|
| 118 | - { |
|
| 119 | - $conditions = []; |
|
| 120 | - foreach ($this->nodes as $filter) { |
|
| 121 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $conditions; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public function getSqlParams(): array |
|
| 131 | - { |
|
| 132 | - $params = []; |
|
| 133 | - foreach ($this->nodes as $filter) { |
|
| 134 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $params; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return INode[] |
|
| 142 | - */ |
|
| 143 | - public function getExtendedNodes(): array |
|
| 144 | - { |
|
| 145 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param string $template |
|
| 150 | - * |
|
| 151 | - * @return INode |
|
| 152 | - */ |
|
| 153 | - public function setTemplate(string $template): INode |
|
| 154 | - { |
|
| 155 | - $this->template = $template; |
|
| 156 | - |
|
| 157 | - return $this; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return string |
|
| 162 | - */ |
|
| 163 | - public function __toString(): string |
|
| 164 | - { |
|
| 165 | - $nodes = Collection::__toString(); |
|
| 166 | - |
|
| 167 | - $form = StringHelper::wrapInTag( |
|
| 168 | - $nodes, |
|
| 169 | - $this->tag, |
|
| 170 | - static::ATTRIBUTES_FORM |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return sprintf( |
|
| 174 | - $this->template, |
|
| 175 | - (string)$this->hiderBtn, |
|
| 176 | - $form |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @return Action |
|
| 182 | - */ |
|
| 183 | - public function getHiderBtn(): Action |
|
| 184 | - { |
|
| 185 | - return $this->hiderBtn; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @return Action |
|
| 190 | - */ |
|
| 191 | - public function getFilterBtn(): Action |
|
| 192 | - { |
|
| 193 | - return $this->filterBtn; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @return Action |
|
| 198 | - */ |
|
| 199 | - public function getResetBtn(): Action |
|
| 200 | - { |
|
| 201 | - return $this->resetBtn; |
|
| 202 | - } |
|
| 203 | -} |
|
@@ -38,166 +38,3 @@ |
||
| 38 | 38 | * %2$s - nodes (filters) |
| 39 | 39 | */ |
| 40 | 40 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 41 | - <div class="hidable"> |
|
| 42 | - <p class="hider">%1$s</p> |
|
| 43 | - <div class="hidee">%2$s</div> |
|
| 44 | - </div> |
|
| 45 | - EOT; |
|
| 46 | - |
|
| 47 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 48 | - |
|
| 49 | - /** @var IFilter[] */ |
|
| 50 | - protected array $nodes = []; |
|
| 51 | - |
|
| 52 | - protected string $nodeClass = IFilter::class; |
|
| 53 | - |
|
| 54 | - protected Action $hiderBtn; |
|
| 55 | - |
|
| 56 | - protected Action $filterBtn; |
|
| 57 | - |
|
| 58 | - protected Action $resetBtn; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Filters constructor. |
|
| 62 | - * |
|
| 63 | - * @param string[] $intents |
|
| 64 | - * @param array $attributes |
|
| 65 | - * @param string|null $tag |
|
| 66 | - */ |
|
| 67 | - public function __construct(array $intents = [], array $attributes = [], ?string $tag = null) |
|
| 68 | - { |
|
| 69 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 70 | - |
|
| 71 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 72 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH); |
|
| 73 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param array $params |
|
| 78 | - * |
|
| 79 | - * @return $this |
|
| 80 | - */ |
|
| 81 | - public function setParams(array $params): Filters |
|
| 82 | - { |
|
| 83 | - foreach ($this->nodes as $filter) { |
|
| 84 | - $filter->setParams($params); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param string $baseUrl |
|
| 92 | - * |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function getUrl(string $baseUrl): string |
|
| 96 | - { |
|
| 97 | - $queryParts = []; |
|
| 98 | - foreach ($this->nodes as $filter) { |
|
| 99 | - $queryPart = $filter->getQueryPart(); |
|
| 100 | - if (!$queryPart) { |
|
| 101 | - continue; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $queryParts[] = $queryPart; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if (empty($queryParts)) { |
|
| 108 | - return $baseUrl; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @return array |
|
| 116 | - */ |
|
| 117 | - public function getWhereConditions(): array |
|
| 118 | - { |
|
| 119 | - $conditions = []; |
|
| 120 | - foreach ($this->nodes as $filter) { |
|
| 121 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $conditions; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public function getSqlParams(): array |
|
| 131 | - { |
|
| 132 | - $params = []; |
|
| 133 | - foreach ($this->nodes as $filter) { |
|
| 134 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $params; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return INode[] |
|
| 142 | - */ |
|
| 143 | - public function getExtendedNodes(): array |
|
| 144 | - { |
|
| 145 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param string $template |
|
| 150 | - * |
|
| 151 | - * @return INode |
|
| 152 | - */ |
|
| 153 | - public function setTemplate(string $template): INode |
|
| 154 | - { |
|
| 155 | - $this->template = $template; |
|
| 156 | - |
|
| 157 | - return $this; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return string |
|
| 162 | - */ |
|
| 163 | - public function __toString(): string |
|
| 164 | - { |
|
| 165 | - $nodes = Collection::__toString(); |
|
| 166 | - |
|
| 167 | - $form = StringHelper::wrapInTag( |
|
| 168 | - $nodes, |
|
| 169 | - $this->tag, |
|
| 170 | - static::ATTRIBUTES_FORM |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return sprintf( |
|
| 174 | - $this->template, |
|
| 175 | - (string)$this->hiderBtn, |
|
| 176 | - $form |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @return Action |
|
| 182 | - */ |
|
| 183 | - public function getHiderBtn(): Action |
|
| 184 | - { |
|
| 185 | - return $this->hiderBtn; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @return Action |
|
| 190 | - */ |
|
| 191 | - public function getFilterBtn(): Action |
|
| 192 | - { |
|
| 193 | - return $this->filterBtn; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @return Action |
|
| 198 | - */ |
|
| 199 | - public function getResetBtn(): Action |
|
| 200 | - { |
|
| 201 | - return $this->resetBtn; |
|
| 202 | - } |
|
| 203 | -} |
|
@@ -165,8 +165,4 @@ |
||
| 165 | 165 | $values = (array)$values; |
| 166 | 166 | |
| 167 | 167 | foreach ($values as $value) { |
| 168 | - header("$name:$value", false); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | -} |
|
| 168 | + header("$name:$value |
|
| 173 | 169 | \ No newline at end of file |
@@ -165,8 +165,4 @@ |
||
| 165 | 165 | $values = (array)$values; |
| 166 | 166 | |
| 167 | 167 | foreach ($values as $value) { |
| 168 | - header("$name:$value", false); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | -} |
|
| 168 | + header("$name:$value |
|
| 173 | 169 | \ No newline at end of file |
@@ -165,8 +165,4 @@ |
||
| 165 | 165 | $values = (array)$values; |
| 166 | 166 | |
| 167 | 167 | foreach ($values as $value) { |
| 168 | - header("$name:$value", false); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | -} |
|
| 168 | + header("$name:$value |
|
| 173 | 169 | \ No newline at end of file |
@@ -165,8 +165,4 @@ |
||
| 165 | 165 | $values = (array)$values; |
| 166 | 166 | |
| 167 | 167 | foreach ($values as $value) { |
| 168 | - header("$name:$value", false); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | -} |
|
| 168 | + header("$name:$value |
|
| 173 | 169 | \ No newline at end of file |
@@ -165,8 +165,4 @@ |
||
| 165 | 165 | $values = (array)$values; |
| 166 | 166 | |
| 167 | 167 | foreach ($values as $value) { |
| 168 | - header("$name:$value", false); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | -} |
|
| 168 | + header("$name:$value |
|
| 173 | 169 | \ No newline at end of file |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | $this->defaultClasses = $defaultClasses; |
| 43 | 43 | $this->intentClassMap = $intentClassMap; |
| 44 | 44 | if (!$callback) { |
| 45 | - $callback = fn ($x) => $x; |
|
| 45 | + $callback = fn($x) => $x; |
|
| 46 | 46 | } |
| 47 | 47 | $this->callback = $callback; |
| 48 | 48 | } |
@@ -80,6 +80,6 @@ |
||
| 80 | 80 | */ |
| 81 | 81 | public function createCanViewViewFunction(?string $username, Enforcer $enforcer): callable |
| 82 | 82 | { |
| 83 | - return fn (string $key) => $enforcer->enforce($username, 'admin_resource_' . $key, Role::READ); |
|
| 83 | + return fn(string $key) => $enforcer->enforce($username, 'admin_resource_' . $key, Role::READ); |
|
| 84 | 84 | } |
| 85 | 85 | } |
@@ -175,7 +175,7 @@ |
||
| 175 | 175 | $transpiler = $container->resolve(ITranspiler::class); |
| 176 | 176 | $transpiler->registerViewFunction( |
| 177 | 177 | 'tr', |
| 178 | - fn (string $key, ...$args) => $translator->translate($key, ...$args) |
|
| 178 | + fn(string $key, ...$args) => $translator->translate($key, ...$args) |
|
| 179 | 179 | ); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | $entities[] = $this->createEntity('bar', 2); |
| 68 | 68 | |
| 69 | 69 | $getters = [ |
| 70 | - 'foo' => fn ($entity) => $entity->getFoo(), |
|
| 70 | + 'foo' => fn($entity) => $entity->getFoo(), |
|
| 71 | 71 | 'bar' => [$entities[0], 'getBar'], |
| 72 | 72 | ]; |
| 73 | 73 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | '/foo?', |
| 132 | 132 | '/foo?sort-A-input=1&sort-B-input=-1&', |
| 133 | 133 | ], |
| 134 | - ] ; |
|
| 134 | + ]; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | ['A' => 'A-input', 'B' => 'B-input'], |
| 148 | 148 | ['A' => 'a_field', 'b' => 'b_field'], |
| 149 | 149 | ['a' => 'A', 'b' => 'B'] |
| 150 | - ) ; |
|
| 150 | + ); |
|
| 151 | 151 | |
| 152 | 152 | $sut->setParams($params); |
| 153 | 153 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | ['A' => 'A-input', 'B' => 'B-input'], |
| 192 | 192 | ['A' => 'a_field', 'B' => 'b_field'], |
| 193 | 193 | ['a' => 'A', 'b' => 'B'] |
| 194 | - ) ; |
|
| 194 | + ); |
|
| 195 | 195 | |
| 196 | 196 | $sut->setParams($params); |
| 197 | 197 | |
@@ -105,6 +105,4 @@ |
||
| 105 | 105 | $this->sut->execute($responseMock); |
| 106 | 106 | $content2 = file_get_contents($this->configUrl); |
| 107 | 107 | |
| 108 | - $this->assertNotSame($content1, $content2); |
|
| 109 | - } |
|
| 110 | -} |
|
| 108 | + $this->assertNotSame($content1, $content2 |
|
| 111 | 109 | \ No newline at end of file |
@@ -105,6 +105,4 @@ |
||
| 105 | 105 | $this->sut->execute($responseMock); |
| 106 | 106 | $content2 = file_get_contents($this->configUrl); |
| 107 | 107 | |
| 108 | - $this->assertNotSame($content1, $content2); |
|
| 109 | - } |
|
| 110 | -} |
|
| 108 | + $this->assertNotSame($content1, $content2 |
|
| 111 | 109 | \ No newline at end of file |
@@ -105,6 +105,4 @@ |
||
| 105 | 105 | $this->sut->execute($responseMock); |
| 106 | 106 | $content2 = file_get_contents($this->configUrl); |
| 107 | 107 | |
| 108 | - $this->assertNotSame($content1, $content2); |
|
| 109 | - } |
|
| 110 | -} |
|
| 108 | + $this->assertNotSame($content1, $content2 |
|
| 111 | 109 | \ No newline at end of file |
@@ -105,6 +105,4 @@ |
||
| 105 | 105 | $this->sut->execute($responseMock); |
| 106 | 106 | $content2 = file_get_contents($this->configUrl); |
| 107 | 107 | |
| 108 | - $this->assertNotSame($content1, $content2); |
|
| 109 | - } |
|
| 110 | -} |
|
| 108 | + $this->assertNotSame($content1, $content2 |
|
| 111 | 109 | \ No newline at end of file |
@@ -105,6 +105,4 @@ |
||
| 105 | 105 | $this->sut->execute($responseMock); |
| 106 | 106 | $content2 = file_get_contents($this->configUrl); |
| 107 | 107 | |
| 108 | - $this->assertNotSame($content1, $content2); |
|
| 109 | - } |
|
| 110 | -} |
|
| 108 | + $this->assertNotSame($content1, $content2 |
|
| 111 | 109 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public function testDoExecuteCallsAllDefaultSubCommands(): void |
| 22 | 22 | { |
| 23 | - $responseMock = $this |
|
| 23 | + $responseMock = $this |
|
| 24 | 24 | ->getMockBuilder(IResponse::class) |
| 25 | 25 | ->disableOriginalConstructor() |
| 26 | 26 | ->getMock(); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function testDoExecuteCallsExtraSubCommands(): void |
| 38 | 38 | { |
| 39 | - $responseMock = $this |
|
| 39 | + $responseMock = $this |
|
| 40 | 40 | ->getMockBuilder(IResponse::class) |
| 41 | 41 | ->disableOriginalConstructor() |
| 42 | 42 | ->getMock(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $ex = new \Exception(); |
| 58 | 58 | |
| 59 | - $responseMock = $this |
|
| 59 | + $responseMock = $this |
|
| 60 | 60 | ->getMockBuilder(IResponse::class) |
| 61 | 61 | ->disableOriginalConstructor() |
| 62 | 62 | ->getMock(); |