1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2012 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
7
|
|
|
* @package Controller |
8
|
|
|
* @subpackage Frontend |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Aimeos\Controller\Frontend; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Common methods for frontend controller classes. |
17
|
|
|
* |
18
|
|
|
* @package Controller |
19
|
|
|
* @subpackage Frontend |
20
|
|
|
*/ |
21
|
|
|
abstract class Base |
22
|
|
|
{ |
23
|
|
|
private $context; |
24
|
|
|
private $object; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Common initialization for controller classes. |
29
|
|
|
* |
30
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Common MShop context object |
31
|
|
|
*/ |
32
|
|
|
public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
33
|
|
|
{ |
34
|
|
|
$this->context = $context; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Catch unknown methods |
40
|
|
|
* |
41
|
|
|
* @param string $name Name of the method |
42
|
|
|
* @param array $param List of method parameter |
43
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
44
|
|
|
*/ |
45
|
|
|
public function __call( $name, array $param ) |
46
|
|
|
{ |
47
|
|
|
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Unable to call method "%1$s"', $name ) ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Returns the context object. |
53
|
|
|
* |
54
|
|
|
* @return \Aimeos\MShop\Context\Item\Iface context object implementing \Aimeos\MShop\Context\Item\Iface |
55
|
|
|
*/ |
56
|
|
|
protected function getContext() |
57
|
|
|
{ |
58
|
|
|
return $this->context; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the outmost decorator of the decorator stack |
64
|
|
|
* |
65
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Outmost decorator object |
66
|
|
|
*/ |
67
|
|
|
protected function getObject() |
68
|
|
|
{ |
69
|
|
|
if( $this->object !== null ) { |
70
|
|
|
return $this->object; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Injects the reference of the outmost object |
79
|
|
|
* |
80
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator |
81
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls |
82
|
|
|
*/ |
83
|
|
|
public function setObject( \Aimeos\Controller\Frontend\Iface $object ) |
84
|
|
|
{ |
85
|
|
|
$this->object = $object; |
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|