Passed
Push — master ( ca8d3f...e8f8af )
by Aimeos
14:31 queued 10:22
created

Standard   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 179
rs 10
wmc 3

3 Methods

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