1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 
<?php
namespace Omeka\View\Helper;

use Zend\View\Helper\AbstractHtmlElement;

/**
 * View helper for rendering a HTML hyperlink.
 */
class Hyperlink extends AbstractHtmlElement
{
    /**
     * Render a HTML hyperlink.
     *
     * @param string|null $text The hyperlink text
     * @param string|null $href The hyperlink href URL
     * @param array $attributes The hyperlink attributes
     * @return string
     */
    public function __invoke($text = null, $href = null, array $attributes = [])
    {
        return $this->raw($this->getView()->escapeHtml($text), $href, $attributes);
    }

    /**
     * Render a HTML hyperlink without escaping the content.
     *
     * @param string|null $html The hyperlink content
     * @param string|null $href The hyperlink href URL
     * @param array $attributes The hyperlink attributes
     * @return string
     */
    public function raw($html = null, $href = null, array $attributes = [])
    {
        $attributes['href'] = $href;
        if (($html === null || $html === '') && isset($attributes['title']) && !isset($attributes['aria-label'])) {
            $attributes['aria-label'] = $attributes['title'];
        }
        return '<a' . $this->htmlAttribs($attributes) . '>' . $html . '</a>';
    }
}