Completed
Push — master ( c1ac02...038e21 )
by Aimeos
02:23
created

Base::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
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\Supplier\Decorator;
12
13
14
/**
15
 * Base for supplier 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\Supplier\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\Supplier\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 supplier filter
64
	 *
65
	 * @param boolean True to add default criteria
66
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
67
	 * @since 2018.07
68
	 */
69
	public function createFilter()
70
	{
71
		return $this->controller->createFilter();
72
	}
73
74
75
	/**
76
	 * Returns the supplier item for the given supplier ID
77
	 *
78
	 * @param string $id Unique supplier ID
79
	 * @param string[] $domains Domain names of items that are associated with the suppliers and that should be fetched too
80
	 * @return \Aimeos\MShop\Supplier\Item\Iface Supplier item including the referenced domains items
81
	 * @since 2018.07
82
	 */
83
	public function getItem( $id, array $domains = array( 'media', 'text' ) )
84
	{
85
		return $this->controller->getItem( $id, $domains );
86
	}
87
88
89
	/**
90
	 * Returns the supplier items for the given supplier IDs
91
	 *
92
	 * @param string $ids Unique supplier IDs
93
	 * @param string[] $domains Domain names of items that are associated with the suppliers and that should be fetched too
94
	 * @return \Aimeos\MShop\Supplier\Item\Iface[] Associative list of supplier item including the referenced domains items
95
	 * @since 2018.07
96
	 */
97
	public function getItems( array $ids, array $domains = array( 'media', 'text' ) )
98
	{
99
		return $this->controller->getItems( $ids, $domains );
100
	}
101
102
103
	/**
104
	 * Returns the suppliers filtered by the given criteria object
105
	 *
106
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
107
	 * @param string[] $domains Domain names of items that are associated with the suppliers and that should be fetched too
108
	 * @param integer &$total Parameter where the total number of found suppliers will be stored in
109
	 * @return array Ordered list of supplier items implementing \Aimeos\MShop\Supplier\Item\Iface
110
	 * @since 2018.07
111
	 */
112
	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'text' ), &$total = null )
113
	{
114
		return $this->controller->searchItems( $filter, $domains, $total );
115
	}
116
117
118
	/**
119
	 * Returns the frontend controller
120
	 *
121
	 * @return \Aimeos\Controller\Frontend\Supplier\Iface Frontend controller object
122
	 */
123
	protected function getController()
124
	{
125
		return $this->controller;
126
	}
127
}
128