Load the Controller object.

@param Controller $controller
540205
public function initialize(Controller $controller) {
        if ($controller->request->is('ajax')) {
            Configure::write('debug', 0);

            // Must disable security component for AJAX
            if (isset($controller->Security)) {
                $controller->Security->validatePost = false;
                $controller->Security->csrfCheck = false;
            }

            // If not from this domain, destroy
            if (!$this->allowRemote && (strpos(env('HTTP_REFERER'), trim(env('HTTP_HOST'), '/')) === false)) {
                if (isset($controller->Security)) {
                    $controller->Security->blackHole($controller, 'Invalid referrer detected for this request.');
                } else {
                    $controller->redirect(null, 403, true);
                }
            }
        }

        $this->controller = $controller;
    }
1314316
public function implicitController($controller)
    {
        $container = $this->getContainer();
        $reflection = $container->getReflection()->setClass($controller);
        $methods = $reflection->getMethods('public', false, null);

        foreach ($methods as $key => $method) {
            if ($method !== '__construct') {
                list($uri, $verb, $method, $plain) = $this->getRoutesParameters($method, $controller, $reflection);
                $args = $this->getUriArguments($plain);

                if (!in_array($verb, $this->verbs)) {
                    throw new \RuntimeException("Invalid HTTP verb ($verb) exception.");
                }

                $classParam = ['controller' => $controller, 'method' => $method, 'args' => $args];

                $this->handleRoute($container, $classParam, $verb, $uri);
            }
        }
    }
493309
public function render($controller = null)
    {
        // Switch current system active module
        $old = $this->system->active($this);

        // If specific controller action should be run
        if (isset($controller)) {
            /**
             * TODO: This would be removed in next major version, here should be
             * passed real controller method for execution.
             */
            $controller = method_exists($this, iModule::OBJ_PREFIX . $controller)
                ? iModule::OBJ_PREFIX . $controller
                : $controller;

            // Define if this is a procedural controller or OOP
            $callback = array($this, $controller);

            // If this controller action is present
            if (method_exists($this, $controller)) {
                // Get passed arguments
                $parameters = func_get_args();
                // Remove first as its a controller action name
                array_shift($parameters);
                // Perform controller action with passed parameters
                call_user_func_array($callback, $parameters);
            } else {
                throw new ControllerActionNotFound($this->id . '#' . $controller);
            }
        }

        // Output view
        echo $this->output();

        // Restore previous active module
        $this->system->active($old);
    }
1128197
protected function uses(String & $controller)
    {
        if( ! empty($this->settings['use']) )
        {
            foreach( $this->settings['use'] as $key => $use )
            {
                if( is_numeric($key) )
                {
                    $controller .= "use {$use};".EOL;
                }
                else
                {
                    $controller .= "use {$key} as {$use};".EOL;
                }
            }

            $controller .= EOL;
        }
    }
236972
public function startup(Controller $controller) {
		$this->Controller = $controller;

		// load the stripe vendor class IF it hasn't been autoloaded (composer)
		App::import('Vendor', 'Stripe.Stripe', array(
			'file' => 'Stripe' . DS . 'lib' . DS . 'Stripe.php')
		);
		if (!class_exists('Stripe')) {
			throw new CakeException('Stripe API library is missing or could not be loaded.');
		}

		// if mode is set in bootstrap.php, use it. otherwise, Test.
		$mode = Configure::read('Stripe.mode');
		if ($mode) {
			$this->mode = $mode;
		}

		// set the Stripe API key
		$this->key = Configure::read('Stripe.' . $this->mode . 'Secret');
		if (!$this->key) {
			throw new CakeException('Stripe API key is not set.');
		}

		// if currency is set in bootstrap.php, use it. otherwise, usd.
		$currency = Configure::read('Stripe.currency');
		if ($currency) {
			$this->currency = $currency;
		}

		// field map for charge response, or use default (set above)
		$fields = Configure::read('Stripe.fields');
		if ($fields) {
			$this->fields = $fields;
		}
	}
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'));
		}
	}
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);
	}
340972
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);
		}
	}
348966
public function setControllerData($controller)
    {
        if (is_string($controller)) {
            $controller = $this->app->normalizeClassName($controller, 'Data');
        } elseif (!$controller instanceof Controller_Data) {
            throw $this->exception('Inappropriate Controller. Must extend Controller_Data');
        }
        $this->controller = $this->setController($controller);

        return $this->controller;
    }
523884
public function startup(Controller $controller) {
		if (!$this->_controller->ViewExtension->isHtml()) {
			return;
		}

		$this->_setConfigVar($controller);
	}
483959
public function startup(Controller $controller) {
		$this->_setConfig();
		if (!$this->_controller->ViewExtension->isHtml()) {
			return;
		}

		$targetDeep = $this->_modelConfigSearchInfo->getTargetDeep();
		$querySearchMinLength = $this->_modelConfigSearchInfo->getQuerySearchMinLength();
		$targetFieldsSelected = $this->getTargetList();
		$targetFields = $this->_modelSearch->getTargetFields();

		$controller->set('search_targetDeep', $targetDeep);
		$controller->set('search_querySearchMinLength', $querySearchMinLength);
		$controller->set('search_targetFieldsSelected', $targetFieldsSelected);
		$controller->set('search_targetFields', $targetFields);
	}
93047
public function setController($controller) {
        $controller = Str::studly($controller);
        if('Controller' != substr($controller, -10)) {
            $controller = $controller . 'Controller';
        }

        $this->controller = $controller;

        return $this;
    }
411523
private function loadController() {
        $controller_name = Inflector::classify($this->controller) . 'Controller';
        $controller_class = $this->controller === 'system' ? 'PowerOn\\Controller\\CoreController' : 'App\\Controller\\' . $controller_name;

        if ( !class_exists($controller_class) ) {
            return FALSE;
        }
        
        return new $controller_class();
    }
1322961
public function controller($controller)
    {

        // Instantiate a string controller
        if (is_string($controller)
            && class_exists($controller)
            && is_subclass_of($controller, 'Bkwld\Decoy\Controllers\Base')) {
            $this->controller_name = $controller;
            $this->controller = new $controller;

            // Apply the parent if one was set
            if ($this->parent_item && $this->controller) {
                $this->controller->parent($this->parent_item);
            }

        // Or, validate a passed controller instance
        } elseif (is_object($controller)
            && is_a($controller, 'Bkwld\Decoy\Controllers\Base')) {
            $this->controller_name = get_class($controller);
            $this->controller = $controller;
        }

        // Chain
        return $this;
    }
569770
public function setController($controller)
        {
            if (null !== $controller && !is_string($controller)) {
                throw new Exception(
                    'Invalid argument: $controller must be a string or null'
                );
            }

            $this->_controller = $controller;
            $this->_hrefCache  = null;

            return $this;
        }
1261595
public function routeController($controller): Controller
    {
        $actions = $this->getActions();

        foreach ($actions as $key => $action) {
            $method = ucfirst(Inflector::pathAction($action));

            if (method_exists($this, 'set' . $method . 'Route')) {
                $this->{'set' . $method . 'Route'}(Inflector::deCamelize($controller), $action);
            }
        }

        $this->mapRoute();

        return $this;
    }
997913
private function createController($controller)
    {
        if (false === strpos($controller, '::'))
        {
            $count = substr_count($controller, ':');
            if (2 == $count)
            {
                // controller in the a:b:c notation then
                $controller = $this->parser->parse($controller);
            }
            elseif (1 == $count)
            {
                // controller in the service:method notation
                list($service, $method) = explode(':', $controller, 2);
                return array($this->kernel->getContainer()->get($service), $method);
            }
            else
            {
                throw new \LogicException(sprintf('Unable to parse the controller name "%s".', $controller));
            }
        }
        list($class, $method) = explode('::', $controller, 2);
        $method .= 'Action';
        if (!class_exists($class))
        {
            throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
        }
        if (!method_exists($class, $method))
        {
            throw new \InvalidArgumentException(sprintf('Method "%s" of "%s" class does not exist.', $method, $class));
        }
        $controller = new $class();
        if ($controller instanceof \Fulgurio\LightCMSBundle\Controller\FrontPageController)
        {
            $controller->setContainer($this->kernel->getContainer());
            $controller->setPage($this->page);
        }
        return array($controller, $method);
    }