/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/View/Helper
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/View/Helper/IdGeneratorTrait.php (2722B)
*/
protected $_idSuffixes = [];
/**
* Clear the stored ID suffixes.
*
* @return void
*/
protected function _clearIds(): void
{
$this->_idSuffixes = [];
}
/**
* Generate an ID attribute for an element.
*
* Ensures that id's for a given set of fields are unique.
*
* @param string $name The ID attribute name.
* @param string $val The ID attribute value.
* @return string Generated id.
*/
protected function _id(string $name, string $val): string
{
$name = $this->_domId($name);
$suffix = $this->_idSuffix($val);
return trim($name . '-' . $suffix, '-');
}
/**
* Generate an ID suffix.
*
* Ensures that id's for a given set of fields are unique.
*
* @param string $val The ID attribute value.
* @return string Generated id suffix.
*/
protected function _idSuffix(string $val): string
{
$idSuffix = mb_strtolower(str_replace(['/', '@', '<', '>', ' ', '"', '\''], '-', $val));
$count = 1;
$check = $idSuffix;
while (in_array($check, $this->_idSuffixes, true)) {
$check = $idSuffix . $count++;
}
$this->_idSuffixes[] = $check;
return $check;
}
/**
* Generate an ID suitable for use in an ID attribute.
*
* @param string $value The value to convert into an ID.
* @return string The generated id.
*/
protected function _domId(string $value): string
{
$domId = mb_strtolower(Text::slug($value, '-'));
if ($this->_idPrefix) {
$domId = $this->_idPrefix . '-' . $domId;
}
return $domId;
}
}