Get controller from parsed string (first match in string like "controller/action")
@return string
@throws NotFoundHttpException
344517
public static function getRequestController()
    {
        $r = explode('/', ltrim(self::getRequestRoute(), '/'));
        if (isset($r[0]) && !empty($r[0]))
            return $r[0];
        else
            throw new NotFoundHttpException(\Yii::t('yii', 'Page not found.'));
    }
1190646
public function getAction()
	{
		$action = strtolower($this->getParam(self::ACTION_PARAM));
		if ($action === '' or ! preg_match('/^[a-z0-9_-]+$/', $action)) {
			return Controller::DEFAULT_ACTION;
		}

		return $action;
	}
556629
private function getController()
        {
            $expected = $this->request['resource'];
            foreach(glob(APPLICATION_PATH . '/Controllers/*.php', GLOB_NOSORT) as $controller) {
                $controller = basename($controller, '.php');
                if(strnatcasecmp($expected, $controller) == 0) {
                    return 'Controllers_' . $controller;
                }
            }
            return null;
        }
1022965
public function instanciateController() {
		$class = $this->controllerClass;
		/* @var Controller $controller */
		$controller = new $class();
		if( !($controller instanceof Controller) ) {
			throw new NotFoundException('The controller "'.$this->controllerClass.'" is not a valid controller, the class must inherit from "'.get_class().'"');
		}
		$controller->setRoute($this);
		return $controller;
	}
296750
private function resolveController(): string
    {
        if (!empty($this->routeParams[0])) {
            $controllerName = implode('', array_map('ucfirst', explode('-', $this->routeParams[0])));

            return $this->configuration->getControllerNamespace() . $controllerName . 'Controller';
        }

        return $this->configuration->getControllerNamespace() . $this->configuration->getDefaultController() . 'Controller';
    }
860676
public function parseControllerString($controllerString)
    {
        $partsArray = explode('@', $controllerString);

        if(count($partsArray) > 2)
        {
            throw new \Exception("Error parsing controller string, too many @'s found. Only use one to destinguish the controller method.", 1);
        }
        else
        {
            if(strpos($partsArray[0], ':'))
            {
                $parts = explode(':', $partsArray[0]);

                $this->controller_name = array_pop($parts);
                $this->controller = $this->controller_name . '.php';
                $this->controller_path = implode('\\', $parts);
            }
            else
            {
                $this->controller_name = $partsArray[0];
                $this->controller = $this->controller_name . '.php';
            }

            $this->action = $partsArray[1];
        }
    }
20658
public function controllerName() {
        $request = $this->stack->getCurrentRequest();
        if ($request instanceof Request) {
            $string = $request->get('_controller');
            $parts = explode('::', $string);
            $controller = $parts[0];
            $pattern = "#Controller\\\([a-zA-Z\\\]*)Controller#";
            $matches = array();
            preg_match($pattern, $controller, $matches);
            if (isset($matches[1])) {
                return strtolower(str_replace('\\', '_', $matches[1]));
            }

            return '';
        }

        return '';
    }
696859
protected function parseMethod()
    {
        $action = $this->request->route()->getActionName();

        // parse index, store, create etc
        if ( preg_match('/@([^\s].+)$/is', $action, $m) ) {
            $controller = $m[1];
            if ( $controller != 'Closure' ) {
                return $controller;
            }
        }

        return false;
    }
988678
public function getAction()
    {
        if (!is_null(self::$action)) {
            return self::$action;
        }
        $controllerParam = array_get($this->routeParams, 'controller');
        $match           = null;

        if (!preg_match("/.+?(?=@)@(.*)/", $controllerParam, $match)) {
            return;
        }
        self::$action = strtolower($match[1]);
        return self::$action;
    }
1234585
public function getController()
    {
        if(!($this->_controller instanceof KControllerInterface))
        {
            //Make sure we have a controller identifier
            if(!($this->_controller instanceof KObjectIdentifier)) {
                $this->setController($this->_controller);
            }

            $config = array(
                'request'    => $this->getRequest(),
                'response'   => $this->getResponse(),
                'user'       => $this->getUser(),
                'dispatched' => $this
            );

            $this->_controller = $this->getObject($this->_controller, $config);

            //Make sure the controller implements KControllerInterface
            if(!$this->_controller instanceof KControllerInterface)
            {
                throw new UnexpectedValueException(
                    'Controller: '.get_class($this->_controller).' does not implement KControllerInterface'
                );
            }
        }

        return $this->_controller;
    }
143343
public static function getGetString(){
		self::init();
		$values=array_filter(self::$variables,function($value){return $value!='';});
		if(empty($values)) return '';
		return '?'.http_build_query($values);
		}
469200
public function getResponse()
    {
        $this->matcher = new UrlMatcher($this->routes, $this->context);

        $this->parameters = $this->matcher->matchRequest($this->request);

        $controller = $this->parameters['_controller'];
        if ($controller === null) {
            $response = new Response();
        } else {
            $this->controller = new $controller($this->request, $this->parameters);
            $response = $this->controller->handler();
        }

        return $response;
    }
59010
private function getControllerFromDynamicMatch($match = array())
    {
        try {
            if (array_key_exists("controller", $match["params"])) {
                return Controller::factory($match["params"]["controller"]);
            }
        } catch (Exception $e) {
            // The controller did not exist, we don't care at this point.
            // We'll just ignore the route.
        }

        return Controller::factory("App");
    }
714174
public function execute($matches) {
		if (is_string($this->callable)) { // If the callable is a string, call the action of controller
			$params = explode('#', $this->callable);

            if (count($params) == 2) {
                $controllerPrefix = $params[0];
                $controllerPrefix = str_replace(':', '\\', $controllerPrefix);

    			$controller = $controllerPrefix."Controller";

    			$controller = new $controller();
    			$action = $params[1].'Action';

    			return call_user_func_array(array($controller, $action), $matches);


    			return $controller->$action();

            } else {
                throw new RouterException('Invalid controller name '.$this->callable);
            }

		} else { // If the callable is a function, execute the function
			return call_user_func_array($this->callable, $matches);
		}
	}
120108
public function actionName() {
        $request = $this->stack->getCurrentRequest();
        if ($request instanceof Request) {
            $pattern = "#::([a-zA-Z]*)Action#";
            $matches = array();
            preg_match($pattern, $request->get('_controller'), $matches);
            if (isset($matches[1])) {
                return strtolower($matches[1]);
            }

            return '';
        }

        return '';
    }
808013
public function getController()
    {
        if (! isset($this->controller)) {
            list ($controller, $this->method) = $this->parseControllerCallback();

            return $this->controller = $this->container->make($controller);
        }

        return $this->controller;
    }
455800
public function getUrl()
    {
        if (empty($this->url)) {
            $url = $this->httpRequest()->getCurrentUrl(true)->getPath();
            // we need to have the trailing slash because of the match inside matchRequest
            // and also when matching the default method, we can do an incorrect match if we don't have the start and end slash
            $this->url = $this->str($url)->trimRight('/')->val() . '/';
        }

        return $this->url;
    }