Completed
Push — master ( 23dd52...34da75 )
by Aimeos
09:25
created

Standard::setHtml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
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-2017
7
 * @package MShop
8
 * @subpackage Common
9
 */
10
11
12
namespace Aimeos\MShop\Common\Item\Helper\Form;
13
14
15
/**
16
 * Default implementation of the helper form item.
17
 *
18
 * @package MShop
19
 * @subpackage Common
20
 */
21
class Standard implements \Aimeos\MShop\Common\Item\Helper\Form\Iface
22
{
23
	private $url;
24
	private $method;
25
	private $values;
26
	private $external;
27
	private $html;
28
29
30
	/**
31
	 * Initializes the object.
32
	 *
33
	 * @param string $url Initial url
34
	 * @param string $method Initial method (e.g. post or get)
35
	 * @param array $values Form parameters implementing \Aimeos\MW\Criteria\Attribute\Iface
36
	 * @param boolean $external True if URL points to an external site, false if it stays on the same site
37
	 * @param string $html Custom HTML for rendering form (e.g. Including JS or custom html)
38
	 */
39
	public function __construct( $url = '', $method = '', array $values = [], $external = true, $html = '' )
40
	{
41
		\Aimeos\MW\Common\Base::checkClassList( '\\Aimeos\\MW\\Criteria\\Attribute\\Iface', $values );
42
43
		$this->url = (string) $url;
44
		$this->external = (bool) $external;
45
		$this->method = (string) $method;
46
		$this->values = $values;
47
		$this->html = $html;
48
	}
49
50
51
	/**
52
	 * Returns if the URL points to an external site.
53
	 *
54
	 * @return boolean True if URL points to an external site, false if it stays on the same site
55
	 */
56
	public function getExternal()
57
	{
58
		return $this->external;
59
	}
60
61
62
	/**
63
	 * Sets if the URL points to an external site.
64
	 *
65
	 * @param boolean $value True if URL points to an external site, false if it stays on the same site
66
	 * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface Item for chaining method calls
67
	 */
68
	public function setExternal( $value )
69
	{
70
		$this->external = (bool) $value;
71
72
		return $this;
73
	}
74
75
76
	/**
77
	 * Returns the url.
78
	 *
79
	 * @return string Url
80
	 */
81
	public function getUrl()
82
	{
83
		return $this->url;
84
	}
85
86
87
	/**
88
	 * Sets the url.
89
	 *
90
	 * @param string $url Url
91
	 * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface Item for chaining method calls
92
	 */
93
	public function setUrl( $url )
94
	{
95
		$this->url = (string) $url;
96
97
		return $this;
98
	}
99
100
101
	/**
102
	 * Returns the method.
103
	 *
104
	 * @return string Method
105
	 */
106
	public function getMethod()
107
	{
108
		return $this->method;
109
	}
110
111
112
	/**
113
	 * Sets the method.
114
	 *
115
	 * @param string $method Method
116
	 * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface Item for chaining method calls
117
	 */
118
	public function setMethod( $method )
119
	{
120
		$this->method = (string) $method;
121
122
		return $this;
123
	}
124
125
126
	/**
127
	 * Returns the value for the given key.
128
	 *
129
	 * @param string $key Unique key
130
	 * @return \Aimeos\MW\Criteria\Attribute\Iface Attribute item for the given key
131
	 */
132
	public function getValue( $key )
133
	{
134
		if( !isset( $this->values[$key] ) ) {
135
			return null;
136
		}
137
138
		return $this->values[$key];
139
	}
140
141
142
	/**
143
	 * Sets the value for the key.
144
	 *
145
	 * @param string $key Unique key
146
	 * @param \Aimeos\MW\Criteria\Attribute\Iface $value Attribute item for the given key
147
	 * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface Item for chaining method calls
148
	 */
149
	public function setValue( $key, \Aimeos\MW\Criteria\Attribute\Iface $value )
150
	{
151
		$this->values[$key] = $value;
152
153
		return $this;
154
	}
155
156
157
	/**
158
	 * Returns the all key/value pairs.
159
	 *
160
	 * @return array Key/value pairs, values implementing \Aimeos\MW\Criteria\Attribute\Iface
161
	 */
162
	public function getValues()
163
	{
164
		return $this->values;
165
	}
166
167
168
169
	/**
170
	 * Returns the custom html.
171
	 *
172
	 * @return string Html
173
	 */
174
	public function getHtml()
175
	{
176
		return $this->html;
177
	}
178
179
180
	/**
181
	 * Sets the custom Html.
182
	 *
183
	 * @param string $html Html
184
	 * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface Item for chaining method calls
185
	 */
186
	public function setHtml( $html )
187
	{
188
		$this->html = (string) $html;
189
190
		return $this;
191
	}
192
193
194
}
195