Standard   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 176
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 176
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

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