Back to BaseController class

Method getName

public string
getName
()
Method to get the controller name
Returns
  • string The name of the dispatcher
Since
  • 3.0
-
  • \Exception

Method getName - Source code

/**
 * Method to get the controller name
 *
 * The dispatcher name is set by default parsed using the classname, or it can be set
 * by passing a $config['name'] in the class constructor
 *
 * @return  string  The name of the dispatcher
 *
 * @since   3.0
 * @throws  \Exception
 */
public function getName()
{
    if (empty($this->name)) {
        $r = null;
        if (!preg_match('/(.*)Controller/i', \get_class($this), $r)) {
            throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500);
        }
        $this->name = strtolower($r[1]);
    }
    return $this->name;
}