closingBracket) { if ($this->isXhtml()) { $this->closingBracket = ' />'; } else { $this->closingBracket = '>'; } } return $this->closingBracket; } /** * Is doctype XHTML? * * @return bool */ protected function isXhtml() { $plugin = $this->getView()->plugin('doctype'); assert($plugin instanceof Doctype); return $plugin->isXhtml(); } /** * Converts an associative array to a string of tag attributes. * * @access public * @param array $attribs From this array, each key-value pair is * converted to an attribute name and value. * @return string The XHTML for the attributes. */ protected function htmlAttribs($attribs) { foreach ((array) $attribs as $key => $val) { if ('id' === $key) { $attribs[$key] = $this->normalizeId($val); } } $helper = $this->getView()->plugin(HtmlAttributes::class); assert($helper instanceof HtmlAttributes); return (string) $helper($attribs); } /** * Normalize an ID * * @param string $value * @return string */ protected function normalizeId($value) { if (false !== strpos($value, '[')) { if ('[]' === substr($value, -2)) { $value = substr($value, 0, strlen($value) - 2); } $value = trim($value, ']'); $value = str_replace('][', '-', $value); $value = str_replace('[', '-', $value); } return $value; } }