Contao\Widget::getAttribute PHP Метод

getAttribute() публичный Метод

Return a single attribute
public getAttribute ( string $strKey ) : string
$strKey string The attribute name
Результат string The attribute markup
    public function getAttribute($strKey)
    {
        if (!isset($this->arrAttributes[$strKey])) {
            return '';
        }
        $varValue = $this->arrAttributes[$strKey];
        // Prevent the autofocus attribute from being added multiple times (see #8281)
        if ($strKey == 'autofocus') {
            unset($this->arrAttributes[$strKey]);
        }
        if ($strKey == 'disabled' || $strKey == 'readonly' || $strKey == 'required' || $strKey == 'autofocus' || $strKey == 'multiple') {
            return ' ' . $strKey;
        } elseif ($varValue != '') {
            return ' ' . $strKey . '="' . \StringUtil::specialchars($varValue) . '"';
        }
        return '';
    }