|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Frontend |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Attribute\Decorator; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Base for attribute frontend controller decorators |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Frontend |
|
19
|
|
|
*/ |
|
20
|
|
|
abstract class Base |
|
21
|
|
|
implements \Aimeos\Controller\Frontend\Common\Decorator\Iface |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
private $context; |
|
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
|
|
|
$iface = '\Aimeos\Controller\Frontend\Attribute\Iface'; |
|
36
|
|
|
if( !( $controller instanceof $iface ) ) |
|
37
|
|
|
{ |
|
38
|
|
|
$msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface ); |
|
39
|
|
|
throw new \Aimeos\Controller\Frontend\Exception( $msg ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$this->context = $context; |
|
43
|
|
|
$this->controller = $controller; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Passes unknown methods to wrapped objects. |
|
49
|
|
|
* |
|
50
|
|
|
* @param string $name Name of the method |
|
51
|
|
|
* @param array $param List of method parameter |
|
52
|
|
|
* @return mixed Returns the value of the called method |
|
53
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
|
54
|
|
|
*/ |
|
55
|
|
|
public function __call( $name, array $param ) |
|
56
|
|
|
{ |
|
57
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns the given search filter with the conditions attached for filtering by type code |
|
63
|
|
|
* |
|
64
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for attribute search |
|
65
|
|
|
* @param array $codes List of attribute type codes |
|
66
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
67
|
|
|
* @since 2017.03 |
|
68
|
|
|
*/ |
|
69
|
|
|
public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes ) |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->controller->addFilterTypes( $filter, $codes ); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Returns the default attribute filter |
|
77
|
|
|
* |
|
78
|
|
|
* @param boolean True to add default criteria |
|
79
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
80
|
|
|
* @since 2017.03 |
|
81
|
|
|
*/ |
|
82
|
|
|
public function createFilter() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->controller->createFilter(); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Returns the attribute item for the given attribute ID |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $id Unique attribute ID |
|
92
|
|
|
* @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
|
93
|
|
|
* @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items |
|
94
|
|
|
* @since 2017.03 |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getItem( $id, array $domains = array( 'media', 'price', 'text' ) ) |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->controller->getItem( $id, $domains ); |
|
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Returns the attributes filtered by the given criteria object |
|
104
|
|
|
* |
|
105
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
|
106
|
|
|
* @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
|
107
|
|
|
* @param integer &$total Parameter where the total number of found attributes will be stored in |
|
108
|
|
|
* @return array Ordered list of attribute items implementing \Aimeos\MShop\Attribute\Item\Iface |
|
109
|
|
|
* @since 2017.03 |
|
110
|
|
|
*/ |
|
111
|
|
|
public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->controller->searchItems( $filter, $domains, $total ); |
|
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Returns the context item |
|
119
|
|
|
* |
|
120
|
|
|
* @return \Aimeos\MShop\Context\Item\Iface Context item object |
|
121
|
|
|
*/ |
|
122
|
|
|
protected function getContext() |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->context; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Returns the frontend controller |
|
130
|
|
|
* |
|
131
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Frontend controller object |
|
132
|
|
|
*/ |
|
133
|
|
|
protected function getController() |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->controller; |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|