|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Frontend |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Subscription\Decorator; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Base for subscription 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\Subscription\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
|
|
|
$iface = '\Aimeos\Controller\Frontend\Subscription\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->controller = $controller; |
|
43
|
|
|
|
|
44
|
|
|
parent::__construct( $context ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Passes unknown methods to wrapped objects. |
|
50
|
|
|
* |
|
51
|
|
|
* @param string $name Name of the method |
|
52
|
|
|
* @param array $param List of method parameter |
|
53
|
|
|
* @return mixed Returns the value of the called method |
|
54
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
|
55
|
|
|
*/ |
|
56
|
|
|
public function __call( $name, array $param ) |
|
57
|
|
|
{ |
|
58
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Cancels an active subscription |
|
64
|
|
|
* |
|
65
|
|
|
* @param string $id Unique subscription ID |
|
66
|
|
|
* @return \Aimeos\MShop\Subscription\Item\Iface Canceled subscription item |
|
67
|
|
|
*/ |
|
68
|
|
|
public function cancel( $id ) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->controller->cancel( $id ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Returns the filter for searching items |
|
76
|
|
|
* |
|
77
|
|
|
* @return \Aimeos\MW\Criteria\Iface Filter object |
|
78
|
|
|
*/ |
|
79
|
|
|
public function createFilter() |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->controller->createFilter(); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Returns the available interval attribute items |
|
87
|
|
|
* |
|
88
|
|
|
* @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of intervals as keys and interval attribute items as values |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getIntervals() |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->controller->getIntervals(); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Returns the subscription item for the given ID |
|
98
|
|
|
* |
|
99
|
|
|
* @param string $id Unique subscription ID |
|
100
|
|
|
* @return \Aimeos\MShop\Subscription\Item\Iface Subscription object |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getItem( $id ) |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->controller->getItem( $id ); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Saves the modified subscription item |
|
110
|
|
|
* |
|
111
|
|
|
* @param \Aimeos\MShop\Subscription\Item\Iface $item Subscription object |
|
112
|
|
|
* @return \Aimeos\MShop\Subscription\Item\Iface Saved subscription item |
|
113
|
|
|
*/ |
|
114
|
|
|
public function saveItem( \Aimeos\MShop\Subscription\Item\Iface $item ) |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->controller->saveItem( $item ); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Returns the subscription items based on the given filter that belong to the current user |
|
122
|
|
|
* |
|
123
|
|
|
* @param \Aimeos\MW\Criteria\Iface Filter object |
|
124
|
|
|
* @param integer &$total|null Variable that will contain the total number of available items |
|
125
|
|
|
* @return \Aimeos\MShop\Subscription\Item\Iface[] Associative list of IDs as keys and subscription objects as values |
|
126
|
|
|
*/ |
|
127
|
|
|
public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->controller->searchItems( $filter, $total ); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Returns the frontend controller |
|
135
|
|
|
* |
|
136
|
|
|
* @return \Aimeos\Controller\Frontend\Subscription\Iface Frontend controller object |
|
137
|
|
|
*/ |
|
138
|
|
|
protected function getController() |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->controller; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|