Back to ToolbarButton class

Method ensureUniqueId

protected string
ensureUniqueId
(string $id)
Make sure the id is unique
Parameters
  • string $id The id string.
Returns
  • string
Since
  • 4.0.0
Class: ToolbarButton
Project: Joomla

Method ensureUniqueId - Source code

/**
 * Make sure the id is unique
 *
 * @param   string  $id  The id string.
 *
 * @return  string
 *
 * @since   4.0.0
 */
protected function ensureUniqueId(string $id) : string
{
    if (\array_key_exists($id, static::$idCounter)) {
        static::$idCounter[$id]++;
        $id .= static::$idCounter[$id];
    } else {
        static::$idCounter[$id] = 0;
    }
    return $id;
}