Passed
Push — master ( 2804bd...934c66 )
by Aimeos
03:16
created

Standard::getSubClientNames()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 36
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), 2017-2022
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Type\Attribute\Property;
12
13
sprintf( 'type/attribute/property' ); // for translation
14
15
16
/**
17
 * Default implementation of attribute list type JQAdm client.
18
 *
19
 * @package Admin
20
 * @subpackage JQAdm
21
 */
22
class Standard
23
	extends \Aimeos\Admin\JQAdm\Type\Base
24
	implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface
25
{
26
	/**
27
	 * Batch update of a resource
28
	 *
29
	 * @return string|null Output to display
30
	 */
31
	public function batch() : ?string
32
	{
33
		return $this->batchBase( 'attribute/property' );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->batchBase('attribute/property') targeting Aimeos\Admin\JQAdm\Base::batchBase() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
	}
35
36
37
	/**
38
	 * Copies a resource
39
	 *
40
	 * @return string|null HTML output
41
	 */
42
	public function copy() : ?string
43
	{
44
		return $this->copyBase( 'attribute/property' );
45
	}
46
47
48
	/**
49
	 * Creates a new resource
50
	 *
51
	 * @return string|null HTML output
52
	 */
53
	public function create() : ?string
54
	{
55
		return $this->createBase( 'attribute/property' );
56
	}
57
58
59
	/**
60
	 * Deletes a resource
61
	 *
62
	 * @return string|null HTML output
63
	 */
64
	public function delete() : ?string
65
	{
66
		return $this->deleteBase( 'attribute/property' );
67
	}
68
69
70
	/**
71
	 * Returns a single resource
72
	 *
73
	 * @return string|null HTML output
74
	 */
75
	public function get() : ?string
76
	{
77
		return $this->getBase( 'attribute/property' );
78
	}
79
80
81
	/**
82
	 * Saves the data
83
	 *
84
	 * @return string|null HTML output
85
	 */
86
	public function save() : ?string
87
	{
88
		return $this->saveBase( 'attribute/property' );
89
	}
90
91
92
	/**
93
	 * Returns a list of resource according to the conditions
94
	 *
95
	 * @return string|null HTML output
96
	 */
97
	public function search() : ?string
98
	{
99
		$view = $this->searchBase( 'attribute/property' );
100
101
		/** admin/jqadm/type/attribute/property/template-list
102
		 * Relative path to the HTML body template for the list type list.
103
		 *
104
		 * The template file contains the HTML code and processing instructions
105
		 * to generate the result shown in the body of the frontend. The
106
		 * configuration string is the path to the template file relative
107
		 * to the templates directory (usually in admin/jqadm/templates).
108
		 *
109
		 * You can overwrite the template file configuration in extensions and
110
		 * provide alternative templates. These alternative templates should be
111
		 * named like the default one but with the string "default" replaced by
112
		 * an unique name. You may use the name of your project for this. If
113
		 * you've implemented an alternative client class as well, "default"
114
		 * should be replaced by the name of the new class.
115
		 *
116
		 * @param string Relative path to the template creating the HTML code
117
		 * @since 2016.04
118
		 * @category Developer
119
		 */
120
		$tplconf = 'admin/jqadm/type/attribute/property/template-list';
121
		$default = 'type/attribute/property/list';
122
123
		return $view->render( $view->config( $tplconf, $default ) );
124
	}
125
126
127
	/**
128
	 * Returns the sub-client given by its name.
129
	 *
130
	 * @param string $type Name of the client propertytype
131
	 * @param string|null $name Name of the sub-client (Default if null)
132
	 * @return \Aimeos\Admin\JQAdm\Iface Sub-client object
133
	 */
134
	public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface
135
	{
136
		/** admin/jqadm/type/attribute/property/decorators/excludes
137
		 * Excludes decorators added by the "common" option from the list type JQAdm client
138
		 *
139
		 * Decorators extend the functionality of a class by adding new aspects
140
		 * (e.g. log what is currently done), executing the methods of the underlying
141
		 * class only in certain conditions (e.g. only for logged in users) or
142
		 * modify what is returned to the caller.
143
		 *
144
		 * This option allows you to remove a decorator added via
145
		 * "client/jqadm/common/decorators/default" before they are wrapped
146
		 * around the JQAdm client.
147
		 *
148
		 *  admin/jqadm/type/attribute/property/decorators/excludes = array( 'decorator1' )
149
		 *
150
		 * This would remove the decorator named "decorator1" from the list of
151
		 * common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via
152
		 * "client/jqadm/common/decorators/default" to the JQAdm client.
153
		 *
154
		 * @param array List of decorator names
155
		 * @since 2018.01
156
		 * @category Developer
157
		 * @see admin/jqadm/common/decorators/default
158
		 * @see admin/jqadm/type/attribute/property/decorators/global
159
		 * @see admin/jqadm/type/attribute/property/decorators/local
160
		 */
161
162
		/** admin/jqadm/type/attribute/property/decorators/global
163
		 * Adds a list of globally available decorators only to the list type JQAdm client
164
		 *
165
		 * Decorators extend the functionality of a class by adding new aspects
166
		 * (e.g. log what is currently done), executing the methods of the underlying
167
		 * class only in certain conditions (e.g. only for logged in users) or
168
		 * modify what is returned to the caller.
169
		 *
170
		 * This option allows you to wrap global decorators
171
		 * ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client.
172
		 *
173
		 *  admin/jqadm/type/attribute/property/decorators/global = array( 'decorator1' )
174
		 *
175
		 * This would add the decorator named "decorator1" defined by
176
		 * "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client.
177
		 *
178
		 * @param array List of decorator names
179
		 * @since 2018.01
180
		 * @category Developer
181
		 * @see admin/jqadm/common/decorators/default
182
		 * @see admin/jqadm/type/attribute/property/decorators/excludes
183
		 * @see admin/jqadm/type/attribute/property/decorators/local
184
		 */
185
186
		/** admin/jqadm/type/attribute/property/decorators/local
187
		 * Adds a list of local decorators only to the list type JQAdm client
188
		 *
189
		 * Decorators extend the functionality of a class by adding new aspects
190
		 * (e.g. log what is currently done), executing the methods of the underlying
191
		 * class only in certain conditions (e.g. only for logged in users) or
192
		 * modify what is returned to the caller.
193
		 *
194
		 * This option allows you to wrap local decorators
195
		 * ("\Aimeos\Admin\JQAdm\Attribute\Propertytype\Decorator\*") around the JQAdm client.
196
		 *
197
		 *  admin/jqadm/type/attribute/property/decorators/local = array( 'decorator2' )
198
		 *
199
		 * This would add the decorator named "decorator2" defined by
200
		 * "\Aimeos\Admin\JQAdm\Attribute\Propertytype\Decorator\Decorator2" only to the JQAdm client.
201
		 *
202
		 * @param array List of decorator names
203
		 * @since 2018.01
204
		 * @category Developer
205
		 * @see admin/jqadm/common/decorators/default
206
		 * @see admin/jqadm/type/attribute/property/decorators/excludes
207
		 * @see admin/jqadm/type/attribute/property/decorators/global
208
		 */
209
		return $this->createSubClient( 'type/attribute/property' . $type, $name );
210
	}
211
212
213
	/**
214
	 * Returns the list of sub-client names configured for the client.
215
	 *
216
	 * @return array List of JQAdm client names
217
	 */
218
	protected function getSubClientNames() : array
219
	{
220
		/** admin/jqadm/type/attribute/property/subparts
221
		 * List of JQAdm sub-clients rendered within the list type section
222
		 *
223
		 * The output of the frontend is composed of the code generated by the JQAdm
224
		 * clients. Each JQAdm client can consist of serveral (or none) sub-clients
225
		 * that are responsible for rendering certain sub-parts of the output. The
226
		 * sub-clients can contain JQAdm clients themselves and therefore a
227
		 * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates
228
		 * the output that is placed inside the container of its parent.
229
		 *
230
		 * At first, always the JQAdm code generated by the parent is printed, then
231
		 * the JQAdm code of its sub-clients. The order of the JQAdm sub-clients
232
		 * determines the order of the output of these sub-clients inside the parent
233
		 * container. If the configured list of clients is
234
		 *
235
		 *  array( "subclient1", "subclient2" )
236
		 *
237
		 * you can easily change the order of the output by reordering the subparts:
238
		 *
239
		 *  admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" )
240
		 *
241
		 * You can also remove one or more parts if they shouldn't be rendered:
242
		 *
243
		 *  admin/jqadm/<clients>/subparts = array( "subclient1" )
244
		 *
245
		 * As the clients only generates structural JQAdm, the layout defined via CSS
246
		 * should support adding, removing or reordering content by a fluid like
247
		 * design.
248
		 *
249
		 * @param array List of sub-client names
250
		 * @since 2018.01
251
		 * @category Developer
252
		 */
253
		return $this->context()->config()->get( 'admin/jqadm/type/attribute/property/subparts', [] );
254
	}
255
256
257
	/**
258
	 * Returns the rendered template including the view data
259
	 *
260
	 * @param \Aimeos\Base\View\Iface $view View object with data assigned
261
	 * @return string HTML output
262
	 */
263
	protected function render( \Aimeos\Base\View\Iface $view ) : string
264
	{
265
		/** admin/jqadm/type/attribute/property/template-item
266
		 * Relative path to the HTML body template for the list type item.
267
		 *
268
		 * The template file contains the HTML code and processing instructions
269
		 * to generate the result shown in the body of the frontend. The
270
		 * configuration string is the path to the template file relative
271
		 * to the templates directory (usually in admin/jqadm/templates).
272
		 *
273
		 * You can overwrite the template file configuration in extensions and
274
		 * provide alternative templates. These alternative templates should be
275
		 * named like the default one but with the string "default" replaced by
276
		 * an unique name. You may use the name of your project for this. If
277
		 * you've implemented an alternative client class as well, "default"
278
		 * should be replaced by the name of the new class.
279
		 *
280
		 * @param string Relative path to the template creating the HTML code
281
		 * @since 2018.01
282
		 * @category Developer
283
		 */
284
		$tplconf = 'admin/jqadm/type/attribute/property/template-item';
285
		$default = 'type/attribute/property/item';
286
287
		return $view->render( $view->config( $tplconf, $default ) );
288
	}
289
}
290