1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016-2017 |
6
|
|
|
* @package Controller |
7
|
|
|
* @subpackage Frontend |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Catalog\Decorator; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base for catalog 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\Catalog\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\Catalog\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
|
|
|
* Returns the default catalog filter |
64
|
|
|
* |
65
|
|
|
* @param boolean True to add default criteria, e.g. status > 0 |
66
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object for filtering |
67
|
|
|
* @since 2017.03 |
68
|
|
|
*/ |
69
|
|
|
public function createFilter() |
70
|
|
|
{ |
71
|
|
|
return $this->controller->createFilter(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Returns the list of categries that are in the path to the root node including the one specified by its ID. |
78
|
|
|
* |
79
|
|
|
* @param integer $id Category ID to start from, null for root node |
80
|
|
|
* @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too |
81
|
|
|
* @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys |
82
|
|
|
* @since 2017.03 |
83
|
|
|
*/ |
84
|
|
|
public function getPath( $id, array $domains = array( 'text', 'media' ) ) |
85
|
|
|
{ |
86
|
|
|
return $this->controller->getPath( $id, $domains ); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Returns the hierarchical catalog tree starting from the given ID. |
92
|
|
|
* |
93
|
|
|
* @param integer|null $id Category ID to start from, null for root node |
94
|
|
|
* @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too |
95
|
|
|
* @param integer $level Constant from \Aimeos\MW\Tree\Manager\Base for the depth of the returned tree, LEVEL_ONE for |
96
|
|
|
* specific node only, LEVEL_LIST for node and all direct child nodes, LEVEL_TREE for the whole tree |
97
|
|
|
* @param \Aimeos\MW\Criteria\Iface|null $search Optional criteria object with conditions |
98
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant |
99
|
|
|
* @since 2017.03 |
100
|
|
|
*/ |
101
|
|
|
public function getTree( $id = null, array $domains = array( 'text', 'media' ), |
102
|
|
|
$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null ) |
103
|
|
|
{ |
104
|
|
|
return $this->controller->getTree( $id, $domains, $level, $search ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Returns the frontend controller |
110
|
|
|
* |
111
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Frontend controller object |
112
|
|
|
*/ |
113
|
|
|
protected function getController() |
114
|
|
|
{ |
115
|
|
|
return $this->controller; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|