Standard   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 173
Duplicated Lines 0 %

Importance

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

3 Methods

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