Back to ApplicationHelper class

Method getComponentName

public static string
getComponentName
(mixed $default = null)
Return the name of the request component [main component]
Parameters
  • string $default The default option
Returns
  • string Option (e.g. com_something)
Since
  • 1.6

Method getComponentName - Source code

/**
 * Return the name of the request component [main component]
 *
 * @param   string  $default  The default option
 *
 * @return  string  Option (e.g. com_something)
 *
 * @since   1.6
 */
public static function getComponentName($default = null)
{
    static $option;
    if ($option) {
        return $option;
    }
    $input = Factory::getApplication()->input;
    $option = strtolower($input->get('option', ''));
    if (empty($option)) {
        $option = $default;
    }
    $input->set('option', $option);
    return $option;
}