1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Aimeos GmbH (aimeos.com), 2024 |
5
|
|
|
* @package Admin |
6
|
|
|
* @subpackage JQAdm |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Admin\JQAdm\Settings\Api; |
11
|
|
|
|
12
|
|
|
sprintf( 'api' ); // for translation |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Default implementation of settings api JQAdm client. |
17
|
|
|
* |
18
|
|
|
* @package Admin |
19
|
|
|
* @subpackage JQAdm |
20
|
|
|
*/ |
21
|
|
|
class Standard |
22
|
|
|
extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base |
23
|
|
|
implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface |
24
|
|
|
{ |
25
|
|
|
/** admin/jqadm/settings/api/name |
26
|
|
|
* Name of the api subpart used by the JQAdm settings implementation |
27
|
|
|
* |
28
|
|
|
* Use "Myname" if your class is named "\Aimeos\Admin\Jqadm\Settings\Api\Myname". |
29
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
30
|
|
|
* |
31
|
|
|
* @param string Last part of the JQAdm class name |
32
|
|
|
* @since 2024.10 |
33
|
|
|
*/ |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Returns the resource |
38
|
|
|
* |
39
|
|
|
* @return string|null HTML output |
40
|
|
|
*/ |
41
|
|
|
public function search() : ?string |
42
|
|
|
{ |
43
|
|
|
$view = $this->object()->data( $this->view() ); |
44
|
|
|
$view->apiBody = parent::search(); |
45
|
|
|
|
46
|
|
|
return $this->render( $view ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Returns the sub-client given by its name. |
52
|
|
|
* |
53
|
|
|
* @param string $type Name of the client type |
54
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
55
|
|
|
* @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
56
|
|
|
*/ |
57
|
|
|
public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface |
58
|
|
|
{ |
59
|
|
|
/** admin/jqadm/settings/api/decorators/excludes |
60
|
|
|
* Excludes decorators added by the "common" option from the settings JQAdm client |
61
|
|
|
* |
62
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
63
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
64
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
65
|
|
|
* modify what is returned to the caller. |
66
|
|
|
* |
67
|
|
|
* This option allows you to remove a decorator added via |
68
|
|
|
* "admin/jqadm/common/decorators/default" before they are wrapped |
69
|
|
|
* around the JQAdm client. |
70
|
|
|
* |
71
|
|
|
* admin/jqadm/settings/api/decorators/excludes = array( 'decorator1' ) |
72
|
|
|
* |
73
|
|
|
* This would remove the decorator named "decorator1" from the list of |
74
|
|
|
* common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via |
75
|
|
|
* "admin/jqadm/common/decorators/default" to the JQAdm client. |
76
|
|
|
* |
77
|
|
|
* @param array List of decorator names |
78
|
|
|
* @since 2024.10 |
79
|
|
|
* @see admin/jqadm/common/decorators/default |
80
|
|
|
* @see admin/jqadm/settings/api/decorators/global |
81
|
|
|
* @see admin/jqadm/settings/api/decorators/local |
82
|
|
|
*/ |
83
|
|
|
|
84
|
|
|
/** admin/jqadm/settings/api/decorators/global |
85
|
|
|
* Adds a list of globally available decorators only to the settings JQAdm client |
86
|
|
|
* |
87
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
88
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
89
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
90
|
|
|
* modify what is returned to the caller. |
91
|
|
|
* |
92
|
|
|
* This option allows you to wrap global decorators |
93
|
|
|
* ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client. |
94
|
|
|
* |
95
|
|
|
* admin/jqadm/settings/api/decorators/global = array( 'decorator1' ) |
96
|
|
|
* |
97
|
|
|
* This would add the decorator named "decorator1" defined by |
98
|
|
|
* "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client. |
99
|
|
|
* |
100
|
|
|
* @param array List of decorator names |
101
|
|
|
* @since 2024.10 |
102
|
|
|
* @see admin/jqadm/common/decorators/default |
103
|
|
|
* @see admin/jqadm/settings/api/decorators/excludes |
104
|
|
|
* @see admin/jqadm/settings/api/decorators/local |
105
|
|
|
*/ |
106
|
|
|
|
107
|
|
|
/** admin/jqadm/settings/api/decorators/local |
108
|
|
|
* Adds a list of local decorators only to the settings 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 local decorators |
116
|
|
|
* ("\Aimeos\Admin\JQAdm\Settings\Decorator\*") around the JQAdm client. |
117
|
|
|
* |
118
|
|
|
* admin/jqadm/settings/api/decorators/local = array( 'decorator2' ) |
119
|
|
|
* |
120
|
|
|
* This would add the decorator named "decorator2" defined by |
121
|
|
|
* "\Aimeos\Admin\JQAdm\Settings\Decorator\Decorator2" only to the JQAdm client. |
122
|
|
|
* |
123
|
|
|
* @param array List of decorator names |
124
|
|
|
* @since 2024.10 |
125
|
|
|
* @see admin/jqadm/common/decorators/default |
126
|
|
|
* @see admin/jqadm/settings/api/decorators/excludes |
127
|
|
|
* @see admin/jqadm/settings/api/decorators/global |
128
|
|
|
*/ |
129
|
|
|
return $this->createSubClient( 'settings/api/' . $type, $name ); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Returns the list of sub-client names configured for the client. |
135
|
|
|
* |
136
|
|
|
* @return array List of JQAdm client names |
137
|
|
|
*/ |
138
|
|
|
protected function getSubClientNames() : array |
139
|
|
|
{ |
140
|
|
|
return $this->context()->config()->get( 'admin/jqadm/settings/api/subparts', [] ); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Returns the rendered template including the view data |
146
|
|
|
* |
147
|
|
|
* @param \Aimeos\Base\View\Iface $view View object with data assigned |
148
|
|
|
* @return string HTML output |
149
|
|
|
*/ |
150
|
|
|
protected function render( \Aimeos\Base\View\Iface $view ) : string |
151
|
|
|
{ |
152
|
|
|
/** admin/jqadm/settings/api/template-item |
153
|
|
|
* Relative path to the HTML body template of the api subpart for settings. |
154
|
|
|
* |
155
|
|
|
* The template file contains the HTML code and processing instructions |
156
|
|
|
* to generate the result shown in the body of the frontend. The |
157
|
|
|
* configuration string is the path to the template file relative |
158
|
|
|
* to the templates directory (usually in templates/admin/jqadm). |
159
|
|
|
* |
160
|
|
|
* You can overwrite the template file configuration in extensions and |
161
|
|
|
* provide alternative templates. These alternative templates should be |
162
|
|
|
* named like the default one but with the string "default" replaced by |
163
|
|
|
* an unique name. You may use the name of your project for this. If |
164
|
|
|
* you've implemented an alternative client class as well, "default" |
165
|
|
|
* should be replaced by the name of the new class. |
166
|
|
|
* |
167
|
|
|
* @param string Relative path to the template creating the HTML code |
168
|
|
|
* @since 2016.04 |
169
|
|
|
*/ |
170
|
|
|
$tplconf = 'admin/jqadm/settings/api/template-item'; |
171
|
|
|
$default = 'settings/item-api'; |
172
|
|
|
|
173
|
|
|
return $view->render( $view->config( $tplconf, $default ) ); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|