Passed
Push — main ( f9f23c...f7616c )
by Aimeos
05:03
created

Base::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021
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 $controller;
25
26
27
	/**
28
	 * Initializes the controller decorator.
29
	 *
30
	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
31
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
32
	 */
33
	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context )
34
	{
35
		parent::__construct( $context );
36
37
		$iface = \Aimeos\Controller\Frontend\Cms\Iface::class;
38
		$this->controller = \Aimeos\MW\Common\Base::checkClass( $iface, $controller );
39
	}
40
41
42
	/**
43
	 * Passes unknown methods to wrapped objects.
44
	 *
45
	 * @param string $name Name of the method
46
	 * @param array $param List of method parameter
47
	 * @return mixed Returns the value of the called method
48
	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
49
	 */
50
	public function __call( string $name, array $param )
51
	{
52
		return @call_user_func_array( array( $this->controller, $name ), $param );
53
	}
54
55
56
	/**
57
	 * Clones objects in controller and resets values
58
	 */
59
	public function __clone()
60
	{
61
		$this->controller = clone $this->controller;
62
	}
63
64
65
	/**
66
	 * Adds generic condition for filtering
67
	 *
68
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
69
	 * @param string $key Search key defined by the cms manager, e.g. "cms.status"
70
	 * @param array|string $value Value or list of values to compare to
71
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
72
	 * @since 2019.04
73
	 */
74
	public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Cms\Iface
75
	{
76
		$this->controller->compare( $operator, $key, $value );
0 ignored issues
show
Bug introduced by
The method compare() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

76
		$this->controller->/** @scrutinizer ignore-call */ 
77
                     compare( $operator, $key, $value );
Loading history...
77
		return $this;
78
	}
79
80
81
	/**
82
	 * Returns the cms for the given cms code
83
	 *
84
	 * @param string $code Unique cms code
85
	 * @return \Aimeos\MShop\Cms\Item\Iface Cms item including the referenced domains items
86
	 * @since 2019.04
87
	 */
88
	public function find( string $code ) : \Aimeos\MShop\Cms\Item\Iface
89
	{
90
		return $this->controller->find( $code );
0 ignored issues
show
Bug introduced by
The method find() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

90
		return $this->controller->/** @scrutinizer ignore-call */ find( $code );
Loading history...
91
	}
92
93
94
	/**
95
	 * Creates a search function string for the given name and parameters
96
	 *
97
	 * @param string $name Name of the search function without parenthesis, e.g. "cms:has"
98
	 * @param array $params List of parameters for the search function with numeric keys starting at 0
99
	 * @return string Search function string that can be used in compare()
100
	 */
101
	public function function( string $name, array $params ) : string
102
	{
103
		return $this->controller->function( $name, $params );
0 ignored issues
show
Bug introduced by
The method function() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

103
		return $this->controller->/** @scrutinizer ignore-call */ function( $name, $params );
Loading history...
104
	}
105
106
107
	/**
108
	 * Returns the cms for the given cms ID
109
	 *
110
	 * @param string $id Unique cms ID
111
	 * @return \Aimeos\MShop\Cms\Item\Iface Cms item including the referenced domains items
112
	 * @since 2019.04
113
	 */
114
	public function get( string $id ) : \Aimeos\MShop\Cms\Item\Iface
115
	{
116
		return $this->controller->get( $id );
0 ignored issues
show
Bug introduced by
The method get() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

116
		return $this->controller->/** @scrutinizer ignore-call */ get( $id );
Loading history...
117
	}
118
119
120
	/**
121
	 * Adds a filter to return only items containing a reference to the given ID
122
	 *
123
	 * @param string $domain Domain name of the referenced item, e.g. "product"
124
	 * @param string|null $type Type code of the reference, e.g. "default" or null for all types
125
	 * @param string|null $refId ID of the referenced item of the given domain or null for all references
126
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
127
	 * @since 2019.10
128
	 */
129
	public function has( string $domain, string $type = null, string $refId = null ) : \Aimeos\Controller\Frontend\Cms\Iface
130
	{
131
		$this->controller->has( $domain, $type, $refId );
0 ignored issues
show
Bug introduced by
The method has() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

131
		$this->controller->/** @scrutinizer ignore-call */ 
132
                     has( $domain, $type, $refId );
Loading history...
132
		return $this;
133
	}
134
135
136
	/**
137
	 * Parses the given array and adds the conditions to the list of conditions
138
	 *
139
	 * @param array $conditions List of conditions, e.g. ['>' => ['cms.dateback' => '2000-01-01 00:00:00']]
140
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
141
	 * @since 2019.04
142
	 */
143
	public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Cms\Iface
144
	{
145
		$this->controller->parse( $conditions );
0 ignored issues
show
Bug introduced by
The method parse() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

145
		$this->controller->/** @scrutinizer ignore-call */ 
146
                     parse( $conditions );
Loading history...
146
		return $this;
147
	}
148
149
150
	/**
151
	 * Returns the cmss filtered by the previously assigned conditions
152
	 *
153
	 * @param int &$total Parameter where the total number of found cmss will be stored in
154
	 * @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Cms\Item\Iface
155
	 * @since 2019.04
156
	 */
157
	public function search( int &$total = null ) : \Aimeos\Map
158
	{
159
		return $this->controller->search( $total );
0 ignored issues
show
Bug introduced by
The method search() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

159
		return $this->controller->/** @scrutinizer ignore-call */ search( $total );
Loading history...
160
	}
161
162
163
	/**
164
	 * Sets the start value and the number of returned cms items for slicing the list of found cms items
165
	 *
166
	 * @param int $start Start value of the first cms item in the list
167
	 * @param int $limit Number of returned cms items
168
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
169
	 * @since 2019.04
170
	 */
171
	public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Cms\Iface
172
	{
173
		$this->controller->slice( $start, $limit );
0 ignored issues
show
Bug introduced by
The method slice() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

173
		$this->controller->/** @scrutinizer ignore-call */ 
174
                     slice( $start, $limit );
Loading history...
174
		return $this;
175
	}
176
177
178
	/**
179
	 * Sets the sorting of the result list
180
	 *
181
	 * @param string|null $key Sorting key of the result list like "cms.label", null for no sorting
182
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
183
	 * @since 2019.04
184
	 */
185
	public function sort( string $key = null ) : \Aimeos\Controller\Frontend\Cms\Iface
186
	{
187
		$this->controller->sort( $key );
0 ignored issues
show
Bug introduced by
The method sort() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

187
		$this->controller->/** @scrutinizer ignore-call */ 
188
                     sort( $key );
Loading history...
188
		return $this;
189
	}
190
191
192
	/**
193
	 * Sets the referenced domains that will be fetched too when retrieving items
194
	 *
195
	 * @param array $domains Domain names of the referenced items that should be fetched too
196
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Cms controller for fluent interface
197
	 * @since 2019.04
198
	 */
199
	public function uses( array $domains ) : \Aimeos\Controller\Frontend\Cms\Iface
200
	{
201
		$this->controller->uses( $domains );
0 ignored issues
show
Bug introduced by
The method uses() does not exist on Aimeos\Controller\Frontend\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Controller\Frontend\Common\Iface or Aimeos\Controller\Frontend\Common\Decorator\Iface or Aimeos\Controller\Fronte...ommon\Decorator\Example. Are you sure you never get one of those? ( Ignorable by Annotation )

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

201
		$this->controller->/** @scrutinizer ignore-call */ 
202
                     uses( $domains );
Loading history...
202
		return $this;
203
	}
204
205
206
	/**
207
	 * Injects the reference of the outmost object
208
	 *
209
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
210
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
211
	 */
212
	public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface
213
	{
214
		parent::setObject( $object );
215
216
		$this->controller->setObject( $object );
217
218
		return $this;
219
	}
220
221
222
	/**
223
	 * Returns the frontend controller
224
	 *
225
	 * @return \Aimeos\Controller\Frontend\Cms\Iface Frontend controller object
226
	 */
227
	protected function getController() : \Aimeos\Controller\Frontend\Cms\Iface
228
	{
229
		return $this->controller;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->controller returns the type Aimeos\Controller\Frontend\Iface which is incompatible with the type-hinted return Aimeos\Controller\Frontend\Cms\Iface.
Loading history...
230
	}
231
}
232