Completed
Push — master ( 9dfb2a...67d3ca )
by Aimeos
09:16
created

Base::setObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2016
7
 * @package MShop
8
 * @subpackage Plugin
9
 */
10
11
12
namespace Aimeos\MShop\Plugin\Provider\Decorator;
13
14
15
/**
16
 * Base decorator methods for plugin provider.
17
 *
18
 * @package MShop
19
 * @subpackage Plugin
20
 */
21
abstract class Base
22
	extends \Aimeos\MShop\Plugin\Provider\Base
23
{
24
	private $object;
25
26
27
	/**
28
	 * Initializes the plugin instance
29
	 *
30
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
31
	 * @param \Aimeos\MShop\Plugin\Item\Iface $item Plugin item object
32
	 * @param \Aimeos\MShop\Plugin\Provider\Iface $provider Plugin provider object
33
	 */
34
	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Plugin\Item\Iface $item,
35
		\Aimeos\MShop\Plugin\Provider\Iface $provider )
36
	{
37
		parent::__construct( $context, $item );
38
39
		$this->object = $provider;
40
	}
41
42
43
	/**
44
	 * Subscribes itself to a publisher
45
	 *
46
	 * @param \Aimeos\MW\Observer\Publisher\Iface $p Object implementing publisher interface
47
	 */
48
	public function register( \Aimeos\MW\Observer\Publisher\Iface $p )
49
	{
50
		$this->object->register( $p );
51
	}
52
53
54
	/**
55
	 * Receives a notification from a publisher object
56
	 *
57
	 * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface
58
	 * @param string $action Name of the action to listen for
59
	 * @param mixed $value Object or value changed in publisher
60
	 * @param boolean True if successful, false if not
61
	 */
62
	public function update( \Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null )
63
	{
64
		return $this->object->update( $order, $action, $value );
65
	}
66
67
68
	/**
69
	 * Injects the outmost object into the decorator stack
70
	 *
71
	 * @param \Aimeos\MShop\Plugin\Provider\Iface $object First object of the decorator stack
72
	 * @return \Aimeos\MShop\Plugin\Provider\Iface Plugin object for chaining method calls
1 ignored issue
show
Documentation introduced by
Should the return type not be Base?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
73
	 */
74
	public function setObject( \Aimeos\MShop\Plugin\Provider\Iface $object )
75
	{
76
		parent::setObject( $object );
77
78
		$this->object->setObject( $object );
79
80
		return $this;
81
	}
82
83
84
	/**
85
	 * Returns the next provider or decorator.
86
	 *
87
	 * @return \Aimeos\MShop\Plugin\Provider\Iface Provider or decorator object
88
	 */
89
	protected function getProvider()
90
	{
91
		return $this->object;
92
	}
93
}
94