Passed
Push — master ( fffd00...313d88 )
by Aimeos
19:45
created

Base   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 222
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 222
rs 10
c 0
b 0
f 0
wmc 16

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __clone() 0 3 1
A parse() 0 4 1
A compare() 0 4 1
A __call() 0 3 1
A __construct() 0 5 1
A has() 0 4 1
A function() 0 3 1
A get() 0 3 1
A find() 0 3 1
A sort() 0 4 1
A getController() 0 3 1
A uses() 0 4 1
A resolve() 0 3 1
A search() 0 3 1
A setObject() 0 7 1
A slice() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2024
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Cms\Decorator;
12
13
14
/**
15
 * Base for cms frontend controller decorators
16
 *
17
 * @package Controller
18
 * @subpackage Frontend
19
 */
20
abstract class Base
21
	extends \Aimeos\Controller\Frontend\Base
22
	implements \Aimeos\Controller\Frontend\Common\Decorator\Iface, \Aimeos\Controller\Frontend\Cms\Iface
23
{
24
	private \Aimeos\Controller\Frontend\Cms\Iface $controller;
25
26
27
	/**
28
	 * Initializes the controller decorator.
29
	 *
30
	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
31
	 * @param \Aimeos\MShop\ContextIface $context Context object with required objects
32
	 */
33
	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\ContextIface $context )
34
	{
35
		parent::__construct( $context );
36
37
		$this->controller = $controller;
38
	}
39
40
41
	/**
42
	 * Passes unknown methods to wrapped objects.
43
	 *
44
	 * @param string $name Name of the method
45
	 * @param array $param List of method parameter
46
	 * @return mixed Returns the value of the called method
47
	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
48
	 */
49
	public function __call( string $name, array $param )
50
	{
51
		return @call_user_func_array( array( $this->controller, $name ), $param );
52
	}
53
54
55
	/**
56
	 * Clones objects in controller and resets values
57
	 */
58
	public function __clone()
59
	{
60
		$this->controller = clone $this->controller;
61
	}
62
63
64
	/**
65
	 * Adds generic condition for filtering
66
	 *
67
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
68
	 * @param string $key Search key defined by the cms manager, e.g. "cms.status"
69
	 * @param array|string $value Value or list of values to compare to
70
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
71
	 * @since 2019.04
72
	 */
73
	public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Cms\Iface
74
	{
75
		$this->controller->compare( $operator, $key, $value );
76
		return $this;
77
	}
78
79
80
	/**
81
	 * Returns the cms for the given cms code
82
	 *
83
	 * @param string $code Unique cms code
84
	 * @return \Aimeos\MShop\Cms\Item\Iface Cms item including the referenced domains items
85
	 * @since 2019.04
86
	 */
87
	public function find( string $code ) : \Aimeos\MShop\Cms\Item\Iface
88
	{
89
		return $this->controller->find( $code );
90
	}
91
92
93
	/**
94
	 * Creates a search function string for the given name and parameters
95
	 *
96
	 * @param string $name Name of the search function without parenthesis, e.g. "cms:has"
97
	 * @param array $params List of parameters for the search function with numeric keys starting at 0
98
	 * @return string Search function string that can be used in compare()
99
	 */
100
	public function function( string $name, array $params ) : string
101
	{
102
		return $this->controller->function( $name, $params );
103
	}
104
105
106
	/**
107
	 * Returns the cms for the given cms ID
108
	 *
109
	 * @param string $id Unique cms ID
110
	 * @return \Aimeos\MShop\Cms\Item\Iface Cms item including the referenced domains items
111
	 * @since 2019.04
112
	 */
113
	public function get( string $id ) : \Aimeos\MShop\Cms\Item\Iface
114
	{
115
		return $this->controller->get( $id );
116
	}
117
118
119
	/**
120
	 * Adds a filter to return only items containing a reference to the given ID
121
	 *
122
	 * @param string $domain Domain name of the referenced item, e.g. "product"
123
	 * @param string|null $type Type code of the reference, e.g. "default" or null for all types
124
	 * @param string|null $refId ID of the referenced item of the given domain or null for all references
125
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
126
	 * @since 2019.10
127
	 */
128
	public function has( string $domain, string $type = null, string $refId = null ) : \Aimeos\Controller\Frontend\Cms\Iface
129
	{
130
		$this->controller->has( $domain, $type, $refId );
131
		return $this;
132
	}
133
134
135
	/**
136
	 * Parses the given array and adds the conditions to the list of conditions
137
	 *
138
	 * @param array $conditions List of conditions, e.g. ['>' => ['cms.dateback' => '2000-01-01 00:00:00']]
139
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
140
	 * @since 2019.04
141
	 */
142
	public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Cms\Iface
143
	{
144
		$this->controller->parse( $conditions );
145
		return $this;
146
	}
147
148
149
	/**
150
	 * Returns the category for the given category URL name
151
	 *
152
	 * @param string $name category URL name
153
	 * @return \Aimeos\MShop\Cms\Item\Iface Cms item including the referenced domains items
154
	 * @since 2023.10
155
	 */
156
	public function resolve( string $name ) : \Aimeos\MShop\Cms\Item\Iface
157
	{
158
		return $this->controller->resolve( $name );
159
	}
160
161
162
	/**
163
	 * Returns the cmss filtered by the previously assigned conditions
164
	 *
165
	 * @param int &$total Parameter where the total number of found cmss will be stored in
166
	 * @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Cms\Item\Iface
167
	 * @since 2019.04
168
	 */
169
	public function search( int &$total = null ) : \Aimeos\Map
170
	{
171
		return $this->controller->search( $total );
172
	}
173
174
175
	/**
176
	 * Sets the start value and the number of returned cms items for slicing the list of found cms items
177
	 *
178
	 * @param int $start Start value of the first cms item in the list
179
	 * @param int $limit Number of returned cms items
180
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
181
	 * @since 2019.04
182
	 */
183
	public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Cms\Iface
184
	{
185
		$this->controller->slice( $start, $limit );
186
		return $this;
187
	}
188
189
190
	/**
191
	 * Sets the sorting of the result list
192
	 *
193
	 * @param string|null $key Sorting key of the result list like "cms.label", null for no sorting
194
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
195
	 * @since 2019.04
196
	 */
197
	public function sort( string $key = null ) : \Aimeos\Controller\Frontend\Cms\Iface
198
	{
199
		$this->controller->sort( $key );
200
		return $this;
201
	}
202
203
204
	/**
205
	 * Sets the referenced domains that will be fetched too when retrieving items
206
	 *
207
	 * @param array $domains Domain names of the referenced items that should be fetched too
208
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
209
	 * @since 2019.04
210
	 */
211
	public function uses( array $domains ) : \Aimeos\Controller\Frontend\Cms\Iface
212
	{
213
		$this->controller->uses( $domains );
214
		return $this;
215
	}
216
217
218
	/**
219
	 * Injects the reference of the outmost object
220
	 *
221
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
222
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
223
	 */
224
	public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface
225
	{
226
		parent::setObject( $object );
227
228
		$this->controller->setObject( $object );
0 ignored issues
show
Bug introduced by
The method setObject() does not exist on Aimeos\Controller\Frontend\Cms\Iface. Since it exists in all sub-types, consider adding an abstract or default implementation to Aimeos\Controller\Frontend\Cms\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

228
		$this->controller->/** @scrutinizer ignore-call */ 
229
                     setObject( $object );
Loading history...
229
230
		return $this;
231
	}
232
233
234
	/**
235
	 * Returns the frontend controller
236
	 *
237
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Frontend controller object
238
	 */
239
	protected function getController() : \Aimeos\Controller\Frontend\Cms\Iface
240
	{
241
		return $this->controller;
242
	}
243
}
244