Call controller when is an object.

@return void
760224
protected function runObject()
    {
        $targetInfos = $this->ctrlRouterInfos->target;
        
        if (
            !is_array($targetInfos) ||
            (is_array($targetInfos) && count($targetInfos) !== 2)
        ) {
            throw new Exception(
                'The route target should be an array with the class name '
                .'(first value) and the method name (second value).',
                self::ERR_RUN_OBJECT_MISSING_DATAS_INTO_TARGET
            );
        }
        
        $class  = $targetInfos[0];
        $method = $targetInfos[1];
        
        if (!class_exists($class)) {
            throw new Exception(
                'Class '.$class.' not found',
                self::ERR_RUN_OBJECT_CLASS_NOT_FOUND
            );
        }
        
        $classInstance = new $class;
        if (!method_exists($classInstance, $method)) {
            throw new Exception(
                'Method '.$method.' not found in class '.$class,
                self::ERR_RUN_OBJECT_METHOD_NOT_FOUND
            );
        }
        
        $classInstance->{$method}();
    }
471524
public function process()
    {
        // Your controller name
        $this->controller = Inflector::classify($this->argument('name')).'Controller';

        // By default we will generate basic controller, if resource set then we will generate
        // REST-ful Resource controller
        $this->setControllerType();

        try {
            $this->makeController();
        } catch (\Exception $e) {
            throw $e;
        }

        $this->info('Controller '.$this->controller.' Generated Successfully By Cygnite Cli.');
    }
781594
public function onInit()
    {
        $func = Util::get($this->params, '{init}', null);
        if (is_callable($func)) {
            $this->mapState = $func($data);
        }
    }
381192
public function initialize(Controller $controller) {
		$this->_controller = $controller;
		if (!$this->_controller->Components->loaded('RequestHandler')) {
			$this->_controller->RequestHandler = $this->_controller->Components->load('RequestHandler');
			$this->_controller->RequestHandler->initialize($this->_controller);
		}
		if (empty($this->modelName)) {
			$this->_model = $this->_controller->{$this->_controller->modelClass};
		} else {
			$this->_model = ClassRegistry::init($this->modelName, true);
			if ($this->_model === false) {
				throw new InternalErrorException(__d('view_extension', 'Invalid name of target model for component'));
			}
		}
		if (!$this->_model->Behaviors->loaded('Tree')) {
			throw new InternalErrorException(__d('view_extension', 'Tree behavior is not loaded'));
		}
	}
1208377
private function run_initializers()
    {
        $method_name = 'init';
        $cn = get_called_class();
        
        # Run ApplicationController's init method.
        if ($inits = $this->getAppControllersMethod($method_name)) {
            foreach ($inits as $init) {
                $init = $init->bindTo($this);
                $init();
            }
        }
        
        $method = $this->selfRefl->getMethod($method_name);
        if ($method->getDeclaringClass()->getName() == $cn) {
            $this->$method_name();
        }
    }
668354
public function runAfter() {
        if($this->_afterController !== null) {
            foreach($this->_afterController as $hookProvider) {
                $hookProvider->doAfter();
            }
        }
    }
1085566
public function init()
    {
        $this->initOptions();

        if ($this->button['position'] === static::BUTTON_OUTSIDE && isset($this->button['label'])) {
            $this->renderButton();
        }

        if ($this->form !== false) {
            $this->beginForm();
        }

        $this->beginModal();

        if (isset($this->body)) {
            if ($this->body instanceof \Closure) {
                echo call_user_func($this->body, $this->model, $this);
            } else {
                echo $this->body;
            }
        }
    }
939735
private function route() : void
    {
        // Parse route
        $parsed = $this->parseRoute();

        // Run error controller when no route matched
        if (!$parsed && isset($this->error_controller)) {
            call_user_func($this->error_controller);
        }
    }
1029779
public function connect()
    {
      if ($this->route) {
        if ($_SERVER['REQUEST_METHOD'] === $this->routeMethod[0] || $this->routeMethod[0] == 'ANY') {

          // If handler is function
          if (is_callable($this->handler)) {
            call_user_func($this->handler, (object) $this->params[0]);
          }
          // // If handler is controller and method name
          else {
            $controller_data =  explode('@', $this->handler);
            $controller = $this->namespace . '\\' . ucwords($controller_data[0]) . 'Controller';
            $action = 'action' . ucwords($controller_data[1]);

            // If class exists
            if (class_exists($controller)) {
              $controllerInstance = new $controller;
            } else {
              exit('Class Not Found');
            }

            // If method exists
            if (method_exists($controllerInstance, $action))	{
              call_user_func_array([$controllerInstance, $action], [(object) $this->params[0]]);
            }	else {
              exit('Controller Method Not Found');
            }
          }
        } else {
          exit('HTTP method not allowed');
        }
      }
      // If route not found
      elseif($this->check($this->routerCollection->getAllRoutes(), parse_url($_SERVER['REQUEST_URI'])['path'])) {
        exit('HTTP method not allowed');
      } else {
        exit('Route Not Found');
      }
    }
1272125
public function run()
    {
        // Creates the current controller instance
        $this->controller = new $this->controller($this->twig);

        // Calls the action method on the controller
        $response = call_user_func([$this->controller, $this->action]);

        // Shows the response
        echo $response;
    }
958662
public function run()
    {
        try
        {
            $this['triggers']->callTrigger('before-match-request', $this);

            $this['request']->attributes->add(
                $this['router']->matchRequest($this['request'])
            );

            $this['triggers']->callTrigger('before-controller-resolver', $this);

            $this['response'] = $this->controllerResolver();
        }
        catch (ResourceNotFoundException $e)
        {
            $this['response'] = (new Controller($this))->serve404();
        }
        catch (\Exception $e)
        {
            $this['response'] = new Response();
            $this['response']->headers->set('Content-Type', 'text/plain');
            $this['response']->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
            $this['response']->setContent($e->getMessage());
        }

        if ($this['x-frame-options']) {
            $this['response']->headers->set('x-frame-options', $this['x-frame-options']);
        }

        $this['response']->prepare($this['request']);

        $this['triggers']->callTrigger('before-send-response', $this);

        $this['response']->send();
    }
87939
public function process(){
    if ( $this->check() ){
      $this->obj = new \stdClass();
      if ( !\is_array($this->info)){
        $this->log("No info in MVC", $this->info);
        die("No info in MVC");
      }
      if ( !$this->controller ){
        $this->controller = new mvc\controller($this, $this->info, $this->data, $this->obj);
      }
      $this->controller->process();
    }
	}
876862
public function callback() {
		$timestamp = date('c');

		// To standardize the way of accessing data, objects are translated to arrays
		$this->auth = $this->recursiveGetObjectVars($this->auth);

		$this->auth['provider'] = $this->strategy['strategy_name'];

		$params = array(
			'auth' => $this->auth,
			'timestamp' => $timestamp,
			'signature' => $this->sign($timestamp)
		);

		$this->shipToCallback($params);
	}
1265127
public function addCurrentController(): void
    {
        $controllerName = Inflector::camelize($this->_frontendData['request']['controller']);
        $this->addController(
            $controllerName . '.' . Inflector::camelize($this->_frontendData['request']['action'])
        );
        $this->addController($controllerName);
    }
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']);
		}
	}
443287
public function execute()
	{
		// Incoming task
		$this->_task = strtolower(\Request::getCmd('task', \Request::getWord('layout', '')));

		// Check if the task is in the taskMap
		if (isset($this->_taskMap[$this->_task]))
		{
			$doTask = $this->_taskMap[$this->_task];
		}
		// Check if the default task is set
		elseif (isset($this->_taskMap['__default']))
		{
			$doTask = $this->_taskMap['__default'];
		}
		// Raise an error (hopefully, this shouldn't happen)
		else
		{
			throw new InvalidTaskException(Lang::txt('The requested task "%s" was not found.', $this->_task), 404);
		}

		$name = $this->_controller;
		$layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
		if (!$this->_controller)
		{
			$cls = get_class($this);
			// Attempt to parse the controller name from the class name
			if ((ucfirst($this->_name) . 'Controller') != $cls
			 && preg_match('/(\w)Controller(.*)/i', $cls, $r))
			{
				$this->_controller = strtolower($r[2]);
				$name   = $this->_controller;
				$layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
			}
			// Namepsaced component
			else if (preg_match('/(.?)Controllers\\\(.*)/i', $cls, $r))
			{
				$this->_controller = strtolower($r[2]);
				$name   = $this->_controller;
				$layout = preg_replace('/[^A-Z0-9_]/i', '', $doTask);
			}
			// No controller name found - single controller component
			else
			{
				$name = $doTask;
			}
		}

		// Instantiate a view with layout the same name as the task
		$this->view = new View(array(
			'base_path' => $this->_basePath,
			'name'      => $name,
			'layout'    => $layout
		));

		// Set some commonly used vars
		$this->view->set('option', $this->_option)
					->set('task', $doTask)
					->set('controller', $this->_controller);

		// Record the actual task being fired
		$doTask .= 'Task';

		// On before do task hook
		$this->_onBeforeDoTask();

		// Call the task
		$this->$doTask();
	}
1188286
public function doInit()
    {
        //extension hook
        $this->extend('onBeforeInit');

        // Safety call
        $this->baseInitCalled = false;
        $this->init();
        if (!$this->baseInitCalled) {
            $class = static::class;
            user_error(
                "init() method on class '{$class}' doesn't call Controller::init()."
                . "Make sure that you have parent::init() included.",
                E_USER_WARNING
            );
        }

        $this->extend('onAfterInit');
    }