Standard::getSubClientNames()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2025
6
 * @package Client
7
 * @subpackage Html
8
 */
9
10
11
namespace Aimeos\Client\Html\Catalog\Count;
12
13
14
/**
15
 * Default implementation of catalog count HTML client.
16
 *
17
 * @package Client
18
 * @subpackage Html
19
 */
20
class Standard
21
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
22
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
23
{
24
	/** client/html/catalog/count/name
25
	 * Class name of the used catalog count client implementation
26
	 *
27
	 * Each default HTML client can be replace by an alternative imlementation.
28
	 * To use this implementation, you have to set the last part of the class
29
	 * name as configuration value so the client factory knows which class it
30
	 * has to instantiate.
31
	 *
32
	 * For example, if the name of the default class is
33
	 *
34
	 *  \Aimeos\Client\Html\Catalog\Count\Standard
35
	 *
36
	 * and you want to replace it with your own version named
37
	 *
38
	 *  \Aimeos\Client\Html\Catalog\Count\Mycount
39
	 *
40
	 * then you have to set the this configuration option:
41
	 *
42
	 *  client/html/catalog/count/name = Mycount
43
	 *
44
	 * The value is the last part of your own class name and it's case sensitive,
45
	 * so take care that the configuration value is exactly named like the last
46
	 * part of the class name.
47
	 *
48
	 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
49
	 * characters are possible! You should always start the last part of the class
50
	 * name with an upper case character and continue only with lower case characters
51
	 * or numbers. Avoid chamel case names like "MyCount"!
52
	 *
53
	 * @param string Last part of the class name
54
	 * @since 2014.03
55
	 */
56
57
58
	/** client/html/catalog/count/subparts
59
	 * List of HTML sub-clients rendered within the catalog count section
60
	 *
61
	 * The output of the frontend is composed of the code generated by the HTML
62
	 * clients. Each HTML client can consist of serveral (or none) sub-clients
63
	 * that are responsible for rendering certain sub-parts of the output. The
64
	 * sub-clients can contain HTML clients themselves and therefore a
65
	 * hierarchical tree of HTML clients is composed. Each HTML client creates
66
	 * the output that is placed inside the container of its parent.
67
	 *
68
	 * At first, always the HTML code generated by the parent is printed, then
69
	 * the HTML code of its sub-clients. The order of the HTML sub-clients
70
	 * determines the order of the output of these sub-clients inside the parent
71
	 * container. If the configured list of clients is
72
	 *
73
	 *  array( "subclient1", "subclient2" )
74
	 *
75
	 * you can easily change the order of the output by reordering the subparts:
76
	 *
77
	 *  client/html/<clients>/subparts = array( "subclient1", "subclient2" )
78
	 *
79
	 * You can also remove one or more parts if they shouldn't be rendered:
80
	 *
81
	 *  client/html/<clients>/subparts = array( "subclient1" )
82
	 *
83
	 * As the clients only generates structural HTML, the layout defined via CSS
84
	 * should support adding, removing or reordering content by a fluid like
85
	 * design.
86
	 *
87
	 * @param array List of sub-client names
88
	 * @since 2014.03
89
	 */
90
	private string $subPartPath = 'client/html/catalog/count/subparts';
91
92
	/** client/html/catalog/count/tree/name
93
	 * Name of the tree part used by the catalog count client implementation
94
	 *
95
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Count\Tree\Myname".
96
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
97
	 *
98
	 * @param string Last part of the client class name
99
	 * @since 2014.03
100
	 */
101
102
	/** client/html/catalog/count/supplier/name
103
	 * Name of the supplier part used by the catalog count client implementation
104
	 *
105
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Count\Attribute\Myname".
106
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
107
	 *
108
	 * @param string Last part of the client class name
109
	 * @since 2018.07
110
	 */
111
112
	/** client/html/catalog/count/attribute/name
113
	 * Name of the attribute part used by the catalog count client implementation
114
	 *
115
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Count\Attribute\Myname".
116
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
117
	 *
118
	 * @param string Last part of the client class name
119
	 * @since 2014.03
120
	 */
121
	private array $subPartNames = ['tree', 'supplier', 'attribute'];
122
123
124
	/**
125
	 * Returns the sub-client given by its name.
126
	 *
127
	 * @param string $type Name of the client type
128
	 * @param string|null $name Name of the sub-client (Default if null)
129
	 * @return \Aimeos\Client\Html\Iface Sub-client object
130
	 */
131
	public function getSubClient( string $type, ?string $name = null ) : \Aimeos\Client\Html\Iface
132
	{
133
		return $this->createSubClient( 'catalog/count/' . $type, $name );
134
	}
135
136
137
	/**
138
	 * Returns the list of sub-client names configured for the client.
139
	 *
140
	 * @return array List of HTML client names
141
	 */
142
	protected function getSubClientNames() : array
143
	{
144
		if( !empty( $count = $this->view()->param( 'count' ) ) ) {
145
			$parts = array_intersect( (array) $count, $this->subPartNames );
146
		} else {
147
			$parts = $this->subPartNames;
148
		}
149
150
		return $this->context()->config()->get( $this->subPartPath, $parts );
151
	}
152
153
154
	/** client/html/catalog/count/template-body
155
	 * Relative path to the HTML body template of the catalog count client.
156
	 *
157
	 * The template file contains the HTML code and processing instructions
158
	 * to generate the result shown in the body of the frontend. The
159
	 * configuration string is the path to the template file relative
160
	 * to the templates directory (usually in templates/client/html).
161
	 *
162
	 * You can overwrite the template file configuration in extensions and
163
	 * provide alternative templates. These alternative templates should be
164
	 * named like the default one but suffixed by
165
	 * an unique name. You may use the name of your project for this. If
166
	 * you've implemented an alternative client class as well, it
167
	 * should be suffixed by the name of the new class.
168
	 *
169
	 * @param string Relative path to the template creating code for the HTML page body
170
	 * @since 2014.03
171
	 * @see client/html/catalog/count/template-header
172
	 */
173
174
	/** client/html/catalog/count/template-header
175
	 * Relative path to the HTML header template of the catalog count client.
176
	 *
177
	 * The template file contains the HTML code and processing instructions
178
	 * to generate the HTML code that is inserted into the HTML page header
179
	 * of the rendered page in the frontend. The configuration string is the
180
	 * path to the template file relative to the templates directory (usually
181
	 * in templates/client/html).
182
	 *
183
	 * You can overwrite the template file configuration in extensions and
184
	 * provide alternative templates. These alternative templates should be
185
	 * named like the default one but suffixed by
186
	 * an unique name. You may use the name of your project for this. If
187
	 * you've implemented an alternative client class as well, it
188
	 * should be suffixed by the name of the new class.
189
	 *
190
	 * @param string Relative path to the template creating code for the HTML page head
191
	 * @since 2014.03
192
	 * @see client/html/catalog/count/template-body
193
	 */
194
195
	/** client/html/catalog/count/decorators/excludes
196
	 * Excludes decorators added by the "common" option from the catalog count html client
197
	 *
198
	 * Decorators extend the functionality of a class by adding new aspects
199
	 * (e.g. log what is currently done), executing the methods of the underlying
200
	 * class only in certain conditions (e.g. only for logged in users) or
201
	 * modify what is returned to the caller.
202
	 *
203
	 * This option allows you to remove a decorator added via
204
	 * "client/html/common/decorators/default" before they are wrapped
205
	 * around the html client.
206
	 *
207
	 *  client/html/catalog/count/decorators/excludes = array( 'decorator1' )
208
	 *
209
	 * This would remove the decorator named "decorator1" from the list of
210
	 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
211
	 * "client/html/common/decorators/default" to the html client.
212
	 *
213
	 * @param array List of decorator names
214
	 * @since 2014.05
215
	 * @see client/html/common/decorators/default
216
	 * @see client/html/catalog/count/decorators/global
217
	 * @see client/html/catalog/count/decorators/local
218
	 */
219
220
	/** client/html/catalog/count/decorators/global
221
	 * Adds a list of globally available decorators only to the catalog count html client
222
	 *
223
	 * Decorators extend the functionality of a class by adding new aspects
224
	 * (e.g. log what is currently done), executing the methods of the underlying
225
	 * class only in certain conditions (e.g. only for logged in users) or
226
	 * modify what is returned to the caller.
227
	 *
228
	 * This option allows you to wrap global decorators
229
	 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
230
	 *
231
	 *  client/html/catalog/count/decorators/global = array( 'decorator1' )
232
	 *
233
	 * This would add the decorator named "decorator1" defined by
234
	 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
235
	 *
236
	 * @param array List of decorator names
237
	 * @since 2014.05
238
	 * @see client/html/common/decorators/default
239
	 * @see client/html/catalog/count/decorators/excludes
240
	 * @see client/html/catalog/count/decorators/local
241
	 */
242
243
	/** client/html/catalog/count/decorators/local
244
	 * Adds a list of local decorators only to the catalog count html client
245
	 *
246
	 * Decorators extend the functionality of a class by adding new aspects
247
	 * (e.g. log what is currently done), executing the methods of the underlying
248
	 * class only in certain conditions (e.g. only for logged in users) or
249
	 * modify what is returned to the caller.
250
	 *
251
	 * This option allows you to wrap local decorators
252
	 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
253
	 *
254
	 *  client/html/catalog/count/decorators/local = array( 'decorator2' )
255
	 *
256
	 * This would add the decorator named "decorator2" defined by
257
	 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
258
	 *
259
	 * @param array List of decorator names
260
	 * @since 2014.05
261
	 * @see client/html/common/decorators/default
262
	 * @see client/html/catalog/count/decorators/excludes
263
	 * @see client/html/catalog/count/decorators/global
264
	 */
265
}
266