HTML element.
*
* @param string $label the label of the element
* @param string $url the @href element of the element
* @param array $attributes the attributes of the element
*/
protected function initialize($label, $url, $attributes)
{
$this->attributes['href'] = $url ?: \URLHelper::getURL();
}
/**
* @return string returns a HTML representation of this hyperlink.
*/
public function __toString()
{
if (
isset($this->attributes['disabled'])
&& $this->attributes['disabled'] !== false
) {
return (string) Button::create($this->label, 'none', $this->attributes);
}
// add "button" to attribute @class
if (empty($this->attributes['class'])) {
$this->attributes['class'] = '';
}
$this->attributes['class'] .= ' button';
// TODO: URLHelper...?!
return sprintf(
'%s',
arrayToHtmlAttributes($this->attributes),
htmlReady($this->label)
);
}
}