Standard   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 115
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 115
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

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