Completed
Push — master ( 584ffd...0607c4 )
by Aimeos
02:55
created

Standard::getSubClient()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 77

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 77
rs 8.5018
c 0
b 0
f 0
cc 1
nc 1
nop 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2021
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Dashboard\Order\Quick;
12
13
14
/**
15
 * Default implementation of dashboard order quick 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/quick/name
25
	 * Name of the quick order subpart used by the JQAdm dashboard implementation
26
	 *
27
	 * Use "Myname" if your class is named "\Aimeos\Admin\Jqadm\Dashboard\Order\Quick\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
	 * @category Developer
33
	 */
34
35
36
	/**
37
	 * Returns a list of resource according to the conditions
38
	 *
39
	 * @return string Output to display
40
	 */
41
	public function search() : ?string
42
	{
43
		$view = $this->getView();
44
45
		$manager = \Aimeos\MShop::create( $this->getContext(), 'locale/currency' );
0 ignored issues
show
Unused Code introduced by
$manager is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
46
		$view->orderQuickBody = parent::search();
47
48
		/** admin/jqadm/dashboard/order/quick/template-list
49
		 * Relative path to the HTML body template of the order quick 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 admin/jqadm/templates).
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
		 * @category Developer
66
		 */
67
		$tplconf = 'admin/jqadm/dashboard/order/quick/template-list';
68
		$default = 'dashboard/item-order-quick-standard';
69
70
		return $view->render( $view->config( $tplconf, $default ) );
71
	}
72
73
74
	/**
75
	 * Returns the sub-client given by its name.
76
	 *
77
	 * @param string $type Name of the client type
78
	 * @param string|null $name Name of the sub-client (Default if null)
79
	 * @return \Aimeos\Admin\JQAdm\Iface Sub-client object
80
	 */
81
	public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface
82
	{
83
		/** admin/jqadm/dashboard/order/quick/decorators/excludes
84
		 * Excludes decorators added by the "common" option from the dashboard JQAdm client
85
		 *
86
		 * Decorators extend the functionality of a class by adding new aspects
87
		 * (e.g. log what is currently done), executing the methods of the underlying
88
		 * class only in certain conditions (e.g. only for logged in users) or
89
		 * modify what is returned to the caller.
90
		 *
91
		 * This option allows you to remove a decorator added via
92
		 * "admin/jqadm/common/decorators/default" before they are wrapped
93
		 * around the JQAdm client.
94
		 *
95
		 *  admin/jqadm/dashboard/order/quick/decorators/excludes = array( 'decorator1' )
96
		 *
97
		 * This would remove the decorator named "decorator1" from the list of
98
		 * common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via
99
		 * "admin/jqadm/common/decorators/default" to the JQAdm client.
100
		 *
101
		 * @param array List of decorator names
102
		 * @since 2018.01
103
		 * @category Developer
104
		 * @see admin/jqadm/common/decorators/default
105
		 * @see admin/jqadm/dashboard/order/quick/decorators/global
106
		 * @see admin/jqadm/dashboard/order/quick/decorators/local
107
		 */
108
109
		/** admin/jqadm/dashboard/order/quick/decorators/global
110
		 * Adds a list of globally available decorators only to the dashboard JQAdm client
111
		 *
112
		 * Decorators extend the functionality of a class by adding new aspects
113
		 * (e.g. log what is currently done), executing the methods of the underlying
114
		 * class only in certain conditions (e.g. only for logged in users) or
115
		 * modify what is returned to the caller.
116
		 *
117
		 * This option allows you to wrap global decorators
118
		 * ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client.
119
		 *
120
		 *  admin/jqadm/dashboard/order/quick/decorators/global = array( 'decorator1' )
121
		 *
122
		 * This would add the decorator named "decorator1" defined by
123
		 * "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client.
124
		 *
125
		 * @param array List of decorator names
126
		 * @since 2018.01
127
		 * @category Developer
128
		 * @see admin/jqadm/common/decorators/default
129
		 * @see admin/jqadm/dashboard/order/quick/decorators/excludes
130
		 * @see admin/jqadm/dashboard/order/quick/decorators/local
131
		 */
132
133
		/** admin/jqadm/dashboard/order/quick/decorators/local
134
		 * Adds a list of local decorators only to the dashboard JQAdm client
135
		 *
136
		 * Decorators extend the functionality of a class by adding new aspects
137
		 * (e.g. log what is currently done), executing the methods of the underlying
138
		 * class only in certain conditions (e.g. only for logged in users) or
139
		 * modify what is returned to the caller.
140
		 *
141
		 * This option allows you to wrap local decorators
142
		 * ("\Aimeos\Admin\JQAdm\Dashboard\Decorator\*") around the JQAdm client.
143
		 *
144
		 *  admin/jqadm/dashboard/order/quick/decorators/local = array( 'decorator2' )
145
		 *
146
		 * This would add the decorator named "decorator2" defined by
147
		 * "\Aimeos\Admin\JQAdm\Dashboard\Decorator\Decorator2" only to the JQAdm client.
148
		 *
149
		 * @param array List of decorator names
150
		 * @since 2018.01
151
		 * @category Developer
152
		 * @see admin/jqadm/common/decorators/default
153
		 * @see admin/jqadm/dashboard/order/quick/decorators/excludes
154
		 * @see admin/jqadm/dashboard/order/quick/decorators/global
155
		 */
156
		return $this->createSubClient( 'dashboard/order/quick/' . $type, $name );
157
	}
158
159
160
	/**
161
	 * Returns the list of sub-client names configured for the client.
162
	 *
163
	 * @return array List of JQAdm client names
164
	 */
165
	protected function getSubClientNames() : array
166
	{
167
		/** admin/jqadm/dashboard/order/quick/subparts
168
		 * List of JQAdm sub-clients rendered within the dashboard order section
169
		 *
170
		 * The output of the frontend is composed of the code generated by the JQAdm
171
		 * clients. Each JQAdm client can consist of serveral (or none) sub-clients
172
		 * that are responsible for rendering certain sub-parts of the output. The
173
		 * sub-clients can contain JQAdm clients themselves and therefore a
174
		 * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates
175
		 * the output that is placed inside the container of its parent.
176
		 *
177
		 * At first, always the JQAdm code generated by the parent is printed, then
178
		 * the JQAdm code of its sub-clients. The order of the JQAdm sub-clients
179
		 * determines the order of the output of these sub-clients inside the parent
180
		 * container. If the configured list of clients is
181
		 *
182
		 *  array( "subclient1", "subclient2" )
183
		 *
184
		 * you can easily change the order of the output by reordering the subparts:
185
		 *
186
		 *  admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" )
187
		 *
188
		 * You can also remove one or more parts if they shouldn't be rendered:
189
		 *
190
		 *  admin/jqadm/<clients>/subparts = array( "subclient1" )
191
		 *
192
		 * As the clients only generates structural JQAdm, the layout defined via CSS
193
		 * should support adding, removing or reordering content by a fluid like
194
		 * design.
195
		 *
196
		 * @param array List of sub-client names
197
		 * @since 2018.01
198
		 * @category Developer
199
		 */
200
		return $this->getContext()->getConfig()->get( 'admin/jqadm/dashboard/order/quick/subparts', [] );
201
	}
202
}
203