/* (non-PHPdoc)
@see \rocket\spec\Spec::createController()
179017
public function lookupController(N2nContext $n2nContext) {
		$controller = ReflectionUtils::createObject($this->controllerLookupId);
		$n2nContext->magicInit($controller);
		return $controller;
	}
734398
private function getController()
    {
        if (empty($this->controllerName)) {
            return null;
        }

        if (isset($this->controller)) {
            return $this->controller;
        }

        $this->controller = $this->createControllerFromClassName($this->controllerName);

        return $this->controller;
    }
935512
private function exec( $controller_name, $args )
	{
		// Process controller
		$compo = explode( '@', $controller_name );

		if ( count( $compo ) <= 1 ) {

			throw new Exception( sprintf( 'Controller action must be defined in %s.', $controller_name ) );

		}

		// Get controller
		require_once(  $this->controllers_path . $compo[0] . '.php' );
		$classname = sprintf( $this->namespace . '\Controllers\%s', $compo[0]);
		$controller = new $classname( $this->view );

		if ( !method_exists( $controller, $compo[1] ) ) {

			throw new Exception( sprintf( 'Controller action "%s" not found in %s.', $compo[1], $compo[0] ) );

		}

		return call_user_func_array( [ $controller, $compo[1] ], $args );
	}
597705
public static function Init(\Puzzlout\Framework\Controllers\BaseController $controller) {
        $viewLoader = new ViewLoader();
        $viewLoader->controller = $controller;
        return $viewLoader;
    }
640427
protected function createController($controller)
    {
        $this->checkClass($controller);
        $handler = Application::container()->make($controller);
        if (! $handler instanceof ControllerInterface) {
            throw new InvalidControllerException(
                "The class '{$controller}' does not implement ControllerInterface."
            );
        }
        return $handler;
    }
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;
	}
105459
public function bindToController()
    {
        if ($this->controller->widget === null) {
            $this->controller->widget = new stdClass;
        }

        $this->controller->widget->{$this->alias} = $this;
    }
464164
protected function loadController() {
		//try to load the controller
		$config = $this->getConfig();
		$controller = null;
		if (!empty($config['controllerConfig']['name'])) {
			$className = $this->getSite()->getControllerClass($config['controllerConfig']['name']);
			if (class_exists($className)) {
				$controller = new $className($this->getSite(),$config['controllerConfig']);
				$controller->evaluate();
			}
		}
		if (!$controller) {
			$this->logger->warn("Did not find Controller Class");
			$this->getSite()->setRedirectUrl($config['PATH_HTTP']);
		}
	}
635049
private function generateController()
    {
        // Figure out the naming
        $controller = Str::plural(ucfirst($this->argument('model')));
        $path = 'app/Http/Controllers/Admin/'.$controller.'.php';
        $file = base_path().'/'.$path;

        // Copy the stub over
        if (!file_exists(dirname($file))) {
            mkdir(dirname($file), 0744, true);
        }
        if (file_exists($file)) {
            return $this->comment('Controller already exists: '.$path);
        }
        file_put_contents($file, str_replace('{{controller}}', $controller, file_get_contents($this->stubs.'/controller.stub')));
        $this->info('Controller created: '.$path);
    }
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
        );
    }
1060475
public function createController(InputInterface $input, OutputInterface $output)
    {
        $controller = $this->getApplication()->find('create:controller');
        $controller_arguments = array(
            'command'   => 'create:model',
            'module'    => $input->getArgument('module'),
            'table'     => $input->getArgument('table'),
            'column'    => $input->getArgument('column')
        );
        $input_controller   = new ArrayInput($controller_arguments);
        $return_controller  = $controller->run($input_controller,$output);
        return $output->writeln($return_controller);
    }
574460
protected function makeController($controller)
	{
		Controller::setFilterer($this->filterer);

		return $this->container->make($controller);
	}
414432
public function setController()
    {
        // Constructs the current controller
        $this->controller = ucfirst(strtolower($this->controller)) . 'Controller';

        // Constructs the current controller with the default path
        $this->controller = self::DEFAULT_PATH . $this->controller;

        // Checks if the current controller is an existing class
        if (!class_exists($this->controller)) {
            
            // Attributes the default path & controller to the current controller
            $this->controller = self::DEFAULT_PATH . self::DEFAULT_CONTROLLER;
        }
    }
1089765
public function controller($controller_name)
    {
        // Retrieving the class and method to launch.
        if (is_null($controller_name)) {
            return null;
        }

        $parts = preg_split('/::|@/', $controller_name);

        if (count($parts) == 1) {
            $parts[1] = '__invoke';
        }

        list($class, $method) = $parts;

        if (!class_exists($class, true)) {
            $class = sprintf('%s\\%s', $this->namespaces['controller'], ucfirst($class));
        }

        $injections = $this->injector($class, $method);

        return [
            'action' => [new $class(), $method],
            'injection' => $injections
        ];
    }
551239
private function createController(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aClasses = array_filter(explode(',', $aFields['CLASS_NAME']));

            foreach ($aClasses as $sClass) {

                $aFields['CLASS_NAME'] = $sClass;
                $this->oOutput->write('Creating controller <comment>' . $sClass . '</comment>... ');

                //  Check for existing controller
                $sPath = static::CONTROLLER_PATH . $sClass . '.php';
                if (file_exists($sPath)) {
                    throw new ControllerExistsException(
                        'Controller "' . $sClass . '" exists already at path "' . $sPath . '"'
                    );
                }

                $this->createFile($sPath, $this->getResource('template/controller.php', $aFields));
                $aCreated[] = $sPath;
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (\Exception $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created models
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created controllers</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw $e;
        }
    }
604025
public PlaceController createController ()
    {
        Class<?> cclass = getControllerClass();
        if (cclass == null) {
            throw new RuntimeException(
                "PlaceConfig.createController() must be overridden.");
        }

        log.warning("Providing backwards compatibility. PlaceConfig." +
                    "createController() should be overridden directly.");
        try {
            return (PlaceController)cclass.newInstance();
        } catch (Exception e) {
            log.warning("Failed to instantiate controller class '" + cclass + "'.", e);
            return null;
        }
    }
1088486
private function generateController()
    {
        // Generate Controller class
        $controllerInstance = Controller::instance($this->columns, $this->viewType, $this);

        $controllerTemplateDir =
            dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Controllers'.DS;

        $controllerInstance->setControllerTemplatePath($controllerTemplateDir);
        $controllerInstance->setApplicationDirectory($this->applicationDir);

        $controllerInstance->setControllerName($this->controller);
        $controllerInstance->setModelName($this->model);
        $controllerInstance->updateTemplate();
        $controllerInstance->generateControllerTemplate();

        $controllerInstance->generate();

        $this->info("Controller $this->controller Generated Successfully!");
    }