Get controller instance.

@return object → controller instance
549300
public static function getInstance()
    {
        $controller = get_called_class();

        if (! isset(self::$instance[$controller])) {
            self::$instance[$controller] = new $controller;
        }

        if (is_null(self::$instance[$controller]->view)) {
            self::getViewInstance(self::$instance[$controller]);
        }

        self::getModelInstance(self::$instance[$controller], $controller);

        return self::$instance[$controller];
    }
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;
        }
584981
public function get_active_controller() {
        if ($gradingmethod = $this->get_active_method()) {
            $controller = $this->get_controller($gradingmethod);
            if ($controller->is_form_available()) {
                return $controller;
            }
        }
        return null;
    }
953826
public function getController()
    {
        if ($this->controller) {
            return $this->controller;
        }
        foreach (array_reverse(ClassInfo::ancestry($this->class)) as $blockClass) {
            $controllerClass = "{$blockClass}Controller";
            if (class_exists($controllerClass)) {
                break;
            }
        }
        if (!class_exists($controllerClass)) {
            throw new ValidationException("Could not find controller class for $this->classname");
        }

        $this->controller = Injector::inst()->create($controllerClass, $this);
        $this->controller->init();

        return $this->controller;
    }
497070
protected function controllerMiddleware()
	{
		list( $class, $method ) = explode( '@', $this->action['uses'] );

		$controller = UniversalBuilder::resolve( $class );

		return ( new ControllerDispatcher( $this->router ) )->getMiddleware( $controller, $method );
	}
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';
    }
391637
protected function getController($controller)
	{
		$stub = $this->files->get(__DIR__.'/stubs/controller.stub');

		// We will explode out the controller name on the naemspace delimiter so we
		// are able to replace a namespace in this stub file. If no namespace is
		// provided we'll just clear out the namespace place-holder locations.
		$segments = explode('\\', $controller);

		$stub = $this->replaceNamespace($segments, $stub);

		return str_replace('{{class}}', last($segments), $stub);
	}
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.'));
    }
565468
public function getRoute()
    {
        /** @var Http $req */
        $req = $this->context->getRequest();
        if (isset($this->map[$req->getControllerName()])) {
            return $this->map[$req->getControllerName()];
        }

        return $this->map[Generic::CONTROLLER_KEY];
    }
164786
public function getController($controller)
    {
        if ($controller == null) return null;
        $controllers = $this->pool[$controller] ?? null;
        if ($controllers == null) {
            $controllers = $this->pool[$controller] = new \SplQueue();
        }
        if (!$controllers->isEmpty()) {
            $controller_instance = $controllers->shift();
            $controller_instance->reUse();
            return $controller_instance;
        }
        if (class_exists($controller)) {
            $controller_instance = new $controller;
            if ($controller_instance instanceof Controller) {
                $controller_instance->core_name = $controller;
                $this->addNewCount($controller);
                return $controller_instance;
            }
        }
        $controller_new = str_replace('/', '\\', $controller);
        $class_name = "app\\Controllers\\$controller_new";
        if (class_exists($class_name)) {
            $controller_instance = new $class_name;
            $controller_instance->core_name = $controller;
            $this->addNewCount($controller);
            return $controller_instance;
        } else {
            if (!$this->allow_ServerController) {
                return null;
            }
            $class_name = "Server\\Controllers\\$controller_new";
            if (class_exists($class_name)) {
                $controller_instance = new $class_name;
                $controller_instance->core_name = $controller;
                $this->addNewCount($controller);
                return $controller_instance;
            } else {
                return null;
            }
        }
    }
697877
public function getController($name)
    {
        $name = AnInflector::singularize($name);

        if (!isset(self::$_controllers['controller.'.$name])) {
            if (strpos($name, '.') == false) {
                $identifier = clone $this->getIdentifier();
                $identifier->name = $name;
                $identifier->path = array('controller');
            } else {
                $identifier = $this->getIdentifier($name);
            }

            $controller = $this->getService($identifier, array('request' => array()));
            self::$_controllers['controller.'.$name] = $controller;
        }

        return self::$_controllers['controller.'.$name];
    }
630271
final protected function getPagesControllerClassName()
    {
        $modules = modules()->getArrayCopy();

        foreach($modules as $module) {
            $controllerClassName = $module->getNamespace() . 'Controllers\Pages';
            if ($module->getNamespace() === 'O2System\Framework\\') {
                $controllerClassName = 'O2System\Framework\Http\Controllers\Pages';
            }

            if(class_exists($controllerClassName)) {
                return $controllerClassName;
                break;
            }
        }

        if(class_exists('O2System\Framework\Http\Controllers\Pages')) {
            return 'O2System\Framework\Http\Controllers\Pages';
        }

        return false;
    }
342773
public function instanceController(): Controller
    {
        $this->sawContainer->setEnvironment(SawEnv::controller());

        return new Controller(
            $this->container->get('WorkCycle'),
            $this->container->get(ControllerCore::class),
            $this->container->get('ControllerServer'),
            $this->container->get(CommandDispatcher::class),
            $this->daemonConfig->getControllerPid() // todo
        );
    }
1217798
public String getController() {
        final StringBuilder controller = new StringBuilder();
        if (getProtocol() != null) {
            controller.append(getProtocol()).append("://");
        }
        if (getHost() != null) {
            controller.append(getHost());
        } else {
            controller.append("localhost");
        }
        if (getPort() > 0) {
            controller.append(':').append(getPort());
        }
        return controller.toString();
    }
237230
private function makeResourceController()
    {
        $stubs = ['index', 'new', 'create', 'show', 'edit', 'update', 'delete'];
        $controllerClass = $this->applicationDir.DS.'Controllers'.DS.$this->controller.'Controller'.EXT;

        if (file_exists($controllerClass)) {
            throw new \Exception("$controllerClass already exists!!");
        }

        /*write operation ->*/
        $filePointer = fopen($controllerClass, 'w') or die('Unable to generate controller');
        $controllerContent = $this->getControllerTemplate();

        $resourceContent = '';
        foreach ($stubs as $key => $template) {
            $resourceContent .= file_get_contents($this->getControllerTemplatePath().$template.'.tpl.stub', true).PHP_EOL;
        }

        $content = $this->replaceTemplate('{%methods%}', $resourceContent, $controllerContent);

        return $this->writeContentToClass($filePointer, $content);
    }
621992
protected function _getControllers()
	{
		if( $this->_controllers === array() )
		{
			$subFolder = str_replace( '_', DIRECTORY_SEPARATOR, $this->_getClassPrefix() );

			foreach( $this->_cntlPaths as $path => $list )
			{
				foreach( $list as $relpath )
				{
					$path .= DIRECTORY_SEPARATOR . $relpath . DIRECTORY_SEPARATOR . $subFolder;

					if( is_dir( $path ) ) {
						$this->_addControllers( new DirectoryIterator( $path ) );
					}
				}
			}
		}

		return $this->_controllers;
	}
1337426
WSController getWSController() {
		if (null == controller) {
			controller = CDI.current().select(WSController.class).get();
//			controller = getCdiBeanResolver().getBean(WSController.class);
		}
		return controller;
	}