|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016-2018 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Frontend |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Service\Decorator; |
|
12
|
|
|
|
|
13
|
|
|
use \Psr\Http\Message\ServerRequestInterface; |
|
14
|
|
|
use \Psr\Http\Message\ResponseInterface; |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Base for service frontend controller decorators |
|
19
|
|
|
* |
|
20
|
|
|
* @package Controller |
|
21
|
|
|
* @subpackage Frontend |
|
22
|
|
|
*/ |
|
23
|
|
|
abstract class Base |
|
24
|
|
|
extends \Aimeos\Controller\Frontend\Base |
|
25
|
|
|
implements \Aimeos\Controller\Frontend\Common\Decorator\Iface, \Aimeos\Controller\Frontend\Service\Iface |
|
26
|
|
|
{ |
|
27
|
|
|
private $controller; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Initializes the controller decorator. |
|
32
|
|
|
* |
|
33
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
|
34
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
37
|
|
|
{ |
|
38
|
|
|
\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Frontend\\Service\\Iface', $controller ); |
|
39
|
|
|
|
|
40
|
|
|
$this->controller = $controller; |
|
41
|
|
|
|
|
42
|
|
|
parent::__construct( $context ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Passes unknown methods to wrapped objects. |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $name Name of the method |
|
50
|
|
|
* @param array $param List of method parameter |
|
51
|
|
|
* @return mixed Returns the value of the called method |
|
52
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __call( $name, array $param ) |
|
55
|
|
|
{ |
|
56
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Returns the service for the given code |
|
62
|
|
|
* |
|
63
|
|
|
* @param string $code Unique service code |
|
64
|
|
|
* @param string[] $domains Domain names of items that are associated with the service and that should be fetched too |
|
65
|
|
|
* @return \Aimeos\MShop\Service\Item\Iface Service item including the referenced domains items |
|
66
|
|
|
* @since 2019.04 |
|
67
|
|
|
*/ |
|
68
|
|
|
public function find( $code, $ref = ['media', 'price', 'text'] ) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->controller->find( $code, $ref ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Returns the service for the given ID |
|
76
|
|
|
* |
|
77
|
|
|
* @param string $id Unique service ID |
|
78
|
|
|
* @param string[] $domains Domain names of items that are associated with the services and that should be fetched too |
|
79
|
|
|
* @return \Aimeos\MShop\Service\Item\Iface Service item including the referenced domains items |
|
80
|
|
|
* @since 2019.04 |
|
81
|
|
|
*/ |
|
82
|
|
|
public function get( $id, $ref = ['media', 'price', 'text'] ) |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->controller->get( $id, $ref ); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Returns the service item for the given ID |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $serviceId Unique service ID |
|
92
|
|
|
* @param array $ref List of domains for which the items referenced by the services should be fetched too |
|
93
|
|
|
* @return \Aimeos\MShop\Service\Provider\Iface Service provider object |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getProvider( $serviceId, $ref = ['media', 'price', 'text'] ) |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->controller->getProvider( $serviceId, $ref ); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Returns the service providers for the given type |
|
103
|
|
|
* |
|
104
|
|
|
* @param string|null $type Service type, e.g. "delivery" (shipping related), "payment" (payment related) or null for all |
|
105
|
|
|
* @param array $ref List of domains for which the items referenced by the services should be fetched too |
|
106
|
|
|
* @return \Aimeos\MShop\Service\Provider\Iface[] List of service IDs as keys and service provider objects as values |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getProviders( $type = null, $ref = ['media', 'price', 'text'] ) |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->controller->getProviders( $type, $ref ); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Processes the service for the given order, e.g. payment and delivery services |
|
116
|
|
|
* |
|
117
|
|
|
* @param \Aimeos\MShop\Order\Item\Iface $orderItem Order which should be processed |
|
118
|
|
|
* @param string $serviceId Unique service item ID |
|
119
|
|
|
* @param array $urls Associative list of keys and the corresponding URLs |
|
120
|
|
|
* (keys are <type>.url-self, <type>.url-success, <type>.url-update where type can be "delivery" or "payment") |
|
121
|
|
|
* @param array $params Request parameters and order service attributes |
|
122
|
|
|
* @return \Aimeos\MShop\Common\Helper\Form\Iface|null Form object with URL, parameters, etc. |
|
123
|
|
|
* or null if no form data is required |
|
124
|
|
|
*/ |
|
125
|
|
|
public function process( \Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params ) |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->controller->process( $orderItem, $serviceId, $urls, $params ); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Updates the order status sent by payment gateway notifications |
|
133
|
|
|
* |
|
134
|
|
|
* @param ServerRequestInterface $request Request object |
|
135
|
|
|
* @param ResponseInterface $response Response object that will contain HTTP status and response body |
|
136
|
|
|
* @param string $code Unique code of the service used for the current order |
|
137
|
|
|
* @return \Psr\Http\Message\ResponseInterface Response object |
|
138
|
|
|
*/ |
|
139
|
|
|
public function updatePush( ServerRequestInterface $request, ResponseInterface $response, $code ) |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->controller->updatePush( $request, $response, $code ); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Updates the payment or delivery status for the given request |
|
147
|
|
|
* |
|
148
|
|
|
* @param ServerRequestInterface $request Request object with parameters and request body |
|
149
|
|
|
* @param string $code Unique code of the service used for the current order |
|
150
|
|
|
* @param string $orderid ID of the order whose payment status should be updated |
|
151
|
|
|
* @return \Aimeos\MShop\Order\Item\Iface $orderItem Order item that has been updated |
|
152
|
|
|
*/ |
|
153
|
|
|
public function updateSync( ServerRequestInterface $request, $code, $orderid ) |
|
154
|
|
|
{ |
|
155
|
|
|
return $this->controller->updateSync( $request, $code, $orderid ); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Returns the frontend controller |
|
161
|
|
|
* |
|
162
|
|
|
* @return \Aimeos\Controller\Frontend\Service\Iface Frontend controller object |
|
163
|
|
|
*/ |
|
164
|
|
|
protected function getController() |
|
165
|
|
|
{ |
|
166
|
|
|
return $this->controller; |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|