Passed
Push — master ( 784870...b33804 )
by Aimeos
03:19
created

Standard::getSubClientNames()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 36
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2019
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Dashboard\Setting;
12
13
14
/**
15
 * Default implementation of dashboard settings JQAdm client.
16
 *
17
 * @package Admin
18
 * @subpackage JQAdm
19
 */
20
class Standard
21
	extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base
22
	implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface
23
{
24
	/** admin/jqadm/dashboard/setting/name
25
	 * Name of the setting subpart used by the JQAdm dashboard implementation
26
	 *
27
	 * Use "Myname" if your class is named "\Aimeos\Admin\Jqadm\Dashboard\Setting\Myname".
28
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
29
	 *
30
	 * @param string Last part of the JQAdm class name
31
	 * @since 2020.01
32
	 * @category Developer
33
	 */
34
35
36
	/**
37
	 * Returns a list of resource according to the conditions
38
	 *
39
	 * @return string admin output to display
40
	 */
41
	public function search()
42
	{
43
		$view = $this->getView();
44
45
		/** admin/jqadm/dashboard/setting/template-list
46
		 * Relative path to the HTML body template of the setting subpart for the dashboard.
47
		 *
48
		 * The template file contains the HTML code and processing instructions
49
		 * to generate the result shown in the body of the frontend. The
50
		 * configuration string is the path to the template file relative
51
		 * to the templates directory (usually in admin/jqadm/templates).
52
		 *
53
		 * You can overwrite the template file configuration in extensions and
54
		 * provide alternative templates. These alternative templates should be
55
		 * named like the default one but with the string "default" replaced by
56
		 * an unique name. You may use the name of your project for this. If
57
		 * you've implemented an alternative client class as well, "default"
58
		 * should be replaced by the name of the new class.
59
		 *
60
		 * @param string Relative path to the template creating the HTML code
61
		 * @since 2020.01
62
		 * @category Developer
63
		 */
64
		$tplconf = 'admin/jqadm/dashboard/setting/template-list';
65
		$default = 'dashboard/list-setting-standard';
66
67
		return $view->render( $view->config( $tplconf, $default ) );
68
	}
69
70
71
	/**
72
	 * Returns the sub-client given by its name.
73
	 *
74
	 * @param string $type Name of the client type
75
	 * @param string|null $name Name of the sub-client (Default if null)
76
	 * @return \Aimeos\Admin\JQAdm\Iface Sub-client object
77
	 */
78
	public function getSubClient( $type, $name = null )
79
	{
80
		/** admin/jqadm/dashboard/setting/decorators/excludes
81
		 * Excludes decorators added by the "common" option from the dashboard JQAdm client
82
		 *
83
		 * Decorators extend the functionality of a class by adding new aspects
84
		 * (e.g. log what is currently done), executing the methods of the underlying
85
		 * class only in certain conditions (e.g. only for logged in users) or
86
		 * modify what is returned to the caller.
87
		 *
88
		 * This option allows you to remove a decorator added via
89
		 * "admin/jqadm/common/decorators/default" before they are wrapped
90
		 * around the JQAdm client.
91
		 *
92
		 *  admin/jqadm/dashboard/setting/decorators/excludes = array( 'decorator1' )
93
		 *
94
		 * This would remove the decorator named "decorator1" from the list of
95
		 * common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via
96
		 * "admin/jqadm/common/decorators/default" to the JQAdm client.
97
		 *
98
		 * @param array List of decorator names
99
		 * @since 2020.01
100
		 * @category Developer
101
		 * @see admin/jqadm/common/decorators/default
102
		 * @see admin/jqadm/dashboard/setting/decorators/global
103
		 * @see admin/jqadm/dashboard/setting/decorators/local
104
		 */
105
106
		/** admin/jqadm/dashboard/setting/decorators/global
107
		 * Adds a list of globally available decorators only to the dashboard JQAdm client
108
		 *
109
		 * Decorators extend the functionality of a class by adding new aspects
110
		 * (e.g. log what is currently done), executing the methods of the underlying
111
		 * class only in certain conditions (e.g. only for logged in users) or
112
		 * modify what is returned to the caller.
113
		 *
114
		 * This option allows you to wrap global decorators
115
		 * ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client.
116
		 *
117
		 *  admin/jqadm/dashboard/setting/decorators/global = array( 'decorator1' )
118
		 *
119
		 * This would add the decorator named "decorator1" defined by
120
		 * "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client.
121
		 *
122
		 * @param array List of decorator names
123
		 * @since 2020.01
124
		 * @category Developer
125
		 * @see admin/jqadm/common/decorators/default
126
		 * @see admin/jqadm/dashboard/setting/decorators/excludes
127
		 * @see admin/jqadm/dashboard/setting/decorators/local
128
		 */
129
130
		/** admin/jqadm/dashboard/setting/decorators/local
131
		 * Adds a list of local decorators only to the dashboard JQAdm client
132
		 *
133
		 * Decorators extend the functionality of a class by adding new aspects
134
		 * (e.g. log what is currently done), executing the methods of the underlying
135
		 * class only in certain conditions (e.g. only for logged in users) or
136
		 * modify what is returned to the caller.
137
		 *
138
		 * This option allows you to wrap local decorators
139
		 * ("\Aimeos\Admin\JQAdm\Dashboard\Decorator\*") around the JQAdm client.
140
		 *
141
		 *  admin/jqadm/dashboard/setting/decorators/local = array( 'decorator2' )
142
		 *
143
		 * This would add the decorator named "decorator2" defined by
144
		 * "\Aimeos\Admin\JQAdm\Dashboard\Decorator\Decorator2" only to the JQAdm client.
145
		 *
146
		 * @param array List of decorator names
147
		 * @since 2020.01
148
		 * @category Developer
149
		 * @see admin/jqadm/common/decorators/default
150
		 * @see admin/jqadm/dashboard/setting/decorators/excludes
151
		 * @see admin/jqadm/dashboard/setting/decorators/global
152
		 */
153
		return $this->createSubClient( 'dashboard/setting/' . $type, $name );
154
	}
155
156
157
	/**
158
	 * Returns the list of sub-client names configured for the client.
159
	 *
160
	 * @return array List of JQAdm client names
161
	 */
162
	protected function getSubClientNames()
163
	{
164
		/** admin/jqadm/dashboard/setting/standard/subparts
165
		 * List of JQAdm sub-clients rendered within the dashboard setting section
166
		 *
167
		 * The output of the frontend is composed of the code generated by the JQAdm
168
		 * clients. Each JQAdm client can consist of serveral (or none) sub-clients
169
		 * that are responsible for rendering certain sub-parts of the output. The
170
		 * sub-clients can contain JQAdm clients themselves and therefore a
171
		 * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates
172
		 * the output that is placed inside the container of its parent.
173
		 *
174
		 * At first, always the JQAdm code generated by the parent is printed, then
175
		 * the JQAdm code of its sub-clients. The setting of the JQAdm sub-clients
176
		 * determines the setting of the output of these sub-clients inside the parent
177
		 * container. If the configured list of clients is
178
		 *
179
		 *  array( "subclient1", "subclient2" )
180
		 *
181
		 * you can easily change the setting of the output by reordering the subparts:
182
		 *
183
		 *  admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" )
184
		 *
185
		 * You can also remove one or more parts if they shouldn't be rendered:
186
		 *
187
		 *  admin/jqadm/<clients>/subparts = array( "subclient1" )
188
		 *
189
		 * As the clients only generates structural JQAdm, the layout defined via CSS
190
		 * should support adding, removing or reordering content by a fluid like
191
		 * design.
192
		 *
193
		 * @param array List of sub-client names
194
		 * @since 2020.01
195
		 * @category Developer
196
		 */
197
		return $this->getContext()->getConfig()->get( 'admin/jqadm/dashboard/setting/standard/subparts', [] );
198
	}
199
}
200