Completed
Push — master ( 452e16...087a76 )
by Aimeos
02:19
created

Base::getServiceAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Service\Decorator;
12
13
14
/**
15
 * Base for service 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\Service\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\Service\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 a list of attributes that are invalid.
64
	 *
65
	 * @param string $serviceId Identifier of the service option chosen by the customer
66
	 * @param array $attributes List of key/value pairs with name of the attribute from attribute definition object as
67
	 * 	key and the string entered by the customer as value
68
	 * @return array List of key/value pairs of attributes keys and an error message for values that are invalid or
69
	 * 	missing
70
	 */
71
	public function checkAttributes( $serviceId, array $attributes )
72
	{
73
		return $this->controller->checkAttributes( $serviceId, $attributes );
74
	}
75
76
77
	/**
78
	 * Returns the service item for the given ID
79
	 *
80
	 * @param string $id Unique service ID
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
81
	 * @param array $ref List of domains for which the items referenced by the services should be fetched too
82
	 * @return \Aimeos\MShop\Service\Item\Iface Service item object
83
	 */
84
	public function getProvider( $serviceId, $ref = ['media', 'price', 'text'] )
85
	{
86
		return $this->controller->getProvider( $serviceId, $ref );
87
	}
88
89
90
	/**
91
	 * Returns the service providers for the given
92
	 *
93
	 * @param string $type Service type, e.g. "delivery" (shipping related) or "payment" (payment related)
94
	 * @param string $serviceId Identifier of one of the service option returned by getService()
0 ignored issues
show
Bug introduced by
There is no parameter named $serviceId. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
95
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
0 ignored issues
show
Bug introduced by
There is no parameter named $basket. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
96
	 * @return array List of attribute definitions implementing \Aimeos\MW\Criteria\Attribute\Iface
97
	 */
98
	public function getProviders( $type, $ref = ['media', 'price', 'text'] )
99
	{
100
		return $this->controller->getProviders( $type, $ref );
101
	}
102
103
104
105
	/**
106
	 * Returns the service items that are available for the service type and the content of the basket.
107
	 *
108
	 * @param string $type Service type, e.g. "delivery" (shipping related) or "payment" (payment related)
109
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket of the user
110
	 * @param array $ref List of domains for which the items referenced by the services should be fetched too
111
	 * @return array List of service items implementing \Aimeos\MShop\Service\Item\Iface with referenced items
112
	 * @deprecated Use getProviders() instead
113
	 */
114
	public function getServices( $type, \Aimeos\MShop\Order\Item\Base\Iface $basket,
115
		$ref = array( 'media', 'price', 'text' ) )
116
	{
117
		return $this->controller->getServices( $type, $basket, $ref );
118
	}
119
120
121
	/**
122
	 * Returns the list of attribute definitions which must be used to render the input form where the customer can
123
	 * enter or chose the required data necessary by the service provider.
124
	 *
125
	 * @param string $type Service type, e.g. "delivery" (shipping related) or "payment" (payment related)
126
	 * @param string $serviceId Identifier of one of the service option returned by getService()
127
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
128
	 * @return array List of attribute definitions implementing \Aimeos\MW\Criteria\Attribute\Iface
129
	 * @deprecated Use getProvider() instead
130
	 */
131
	public function getServiceAttributes( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket )
132
	{
133
		return $this->controller->getServiceAttributes( $type, $serviceId, $basket );
134
	}
135
136
137
	/**
138
	 * Returns the price of the service.
139
	 *
140
	 * @param string $type Service type, e.g. "delivery" (shipping related) or "payment" (payment related)
141
	 * @param string $serviceId Identifier of one of the service option returned by getService()
142
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket with products
143
	 * @return \Aimeos\MShop\Price\Item\Iface Price item
144
	 * @throws \Aimeos\Controller\Frontend\Service\Exception If no active service provider for this ID is available
145
	 * @throws \Aimeos\MShop\Exception If service provider isn't available
146
	 * @throws \Exception If an error occurs
147
	 * @deprecated Use getProvider() instead
148
	 */
149
	public function getServicePrice( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket )
150
	{
151
		return $this->controller->getServicePrice( $type, $serviceId, $basket );
152
	}
153
154
155
	/**
156
	 * Returns a list of attributes that are invalid.
157
	 *
158
	 * @param string $type Service type, e.g. "delivery" (shipping related) or "payment" (payment related)
159
	 * @param string $serviceId Identifier of the service option chosen by the customer
160
	 * @param array $attributes List of key/value pairs with name of the attribute from attribute definition object as
161
	 * 	key and the string entered by the customer as value
162
	 * @return array List of key/value pairs of attributes keys and an error message for values that are invalid or
163
	 * 	missing
164
	 * @deprecated Use checkAttributes() instead
165
	 */
166
	public function checkServiceAttributes( $type, $serviceId, array $attributes )
167
	{
168
		return $this->controller->checkServiceAttributes( $type, $serviceId, $attributes );
169
	}
170
171
172
	/**
173
	 * Returns the frontend controller
174
	 *
175
	 * @return \Aimeos\Controller\Frontend\Service\Iface Frontend controller object
176
	 */
177
	protected function getController()
178
	{
179
		return $this->controller;
180
	}
181
}
182