Set the controller data of this model.

@param string|Controller_Data $controller

@return Controller_Data
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;
    }
644295
public function controllerWithoutPrefix($controller)
    {
        $controller = new ReflectionClass($controller);
        $methods = $controller->getMethods(ReflectionMethod::IS_PUBLIC);
        return $this->collectControllerRoutes($controller, $methods, "/");
    }
1162572
public function makeController($controller)
    {
        $namespace = $this->router->getNamespace();

        $classname = "{$namespace}\\{$controller}";

        if (class_exists($classname)) {
            return $this->container->make($classname);
        }

        throw new RoutingException("Controller [{$classname}] do not exists.");
    }
973453
public function setController($controller, $name = null)
    {
        $controller = $this->app->normalizeClassName($controller, 'Controller');

        return $this->add($controller, $name);
    }
1204205
public function setViewController($controller)
    {
        if (is_scalar($controller) || is_resource($controller)) {
            throw new InvalidArgumentException(
                'View controller must be an object, null or an array'
            );
        }

        $this->viewController = $controller;

        return $this;
    }
856137
protected function makeController($controller)
	{
		Controller::setRouter($this->router);

		return $this->container->make($controller);
	}
723516
protected function addMethodToController($controller, $controllerMethod)
    {
        $tmpfile = $this->createTmpFileWithMethod($controllerMethod);
        $path = $this->getPath($tmpfile);
        add_file_into_file('\/\/', $path, app_path('Http/Controllers/' . $controller . '.php'));
    }
702313
protected function _setLayout(Controller &$controller) {
		if ($controller->name == 'CakeError') {
			$controller->layout = 'CakeTheme.error';

			return;
		}

		$isAjax = $controller->request->is('ajax');
		$isPjax = $controller->request->is('pjax');
		$isHtml = $this->_controller->ViewExtension->isHtml();
		if ($isPjax) {
			$controller->layout = 'CakeTheme.pjax';
		} elseif ($isHtml && !$isAjax) {
			if ($controller->request->param('controller') === 'users') {
				$controller->layout = 'CakeTheme.login';
			} else {
				if ($controller->layout === 'default') {
					$controller->layout = 'CakeTheme.main';
				}
			}
		}
	}
1121413
protected function createController($controller)
    {
        if (false === strpos($controller, '::')) {
            throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
        }

        list($class, $method) = explode('::', $controller, 2);

        if ($this->container->has($class)) {
            $controller = $this->container->get($class);
        } else {
            if ( ! class_exists($class)) {
                throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
            }

            $controller = new $class();
        }

        if ($controller instanceof ContainerAwareInterface) {
            $controller->setContainer($this->container);
        }

        return array($controller, $method);
    }
1144860
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 (!$this->_controller->Components->loaded('Session')) {
			$this->_controller->Session = $this->_controller->Components->load('Session');
			$this->_controller->Session->initialize($this->_controller);
		}
		if ($this->_controller->Auth->loggedIn() ||
			$this->_controller->RequestHandler->prefers('json')) {
			return;
		}

		$isAuthCfg = $this->_modelSetting->isAuthGroupConfigured();
		if ($isAuthCfg) {
			if ($this->_controller->Session->read('Settings.FirstLogon')) {
				$this->_controller->Session->delete('Settings.FirstLogon');

				return $this->_controller->redirect($this->_controller->Auth->logout());
			}

			return;
		}

		$pluginName = $this->_controller->request->param('plugin');
		$controllerName = $this->_controller->request->param('controller');
		$actionName = $this->_controller->request->param('action');
		if (($pluginName !== 'cake_settings_app') ||
			($controllerName !== 'settings') ||
			($actionName !== 'index')) {
			return;
		}

		$this->_controller->Auth->allow('index');
		$this->_controller->Session->write('Settings.FirstLogon', true);
	}
898083
public function setController(Controller $controller)
    {
        $this->_Controller = $controller;
        $this->setEventManager($controller->getEventManager());
    }
1369435
protected function createController($controller)
    {
        if (false === strpos($controller, '::')) {
            throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
        }

        list($class, $method) = explode('::', $controller, 2);

        if (!class_exists($class)) {
            throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
        }

        return array(new $class(), $method);
    }
413466
protected function setMetaTags(Controller $controller)
    {
        $controller->setMeta(array('charset' => 'utf-8'));
        $controller->setMeta(array('http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge'));
        $controller->setMeta(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1'));
        $controller->setMeta(array('name' => 'author', 'content' => 'GPLCart'));
    }
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;
    }
162625
public function setController(string $controller): RouteInterface
   {
       if (!preg_match(
               "/^([A-Z]{1}[a-zA-Z_0-9]{1,31}(\/{1})?){1,3}$/",
               $controller)) {
           throw new InvalidArgumentException(
               "Can't set controller: invalid relative controller class name "
             . $controller);
       }
       $this->controller = rtrim($controller, "/");
       return $this;
   }
1141974
private function callControllerMethod(Controller $controller, $method)
    {
        return App::call([$controller, $method], ParameterBag::getParameters());
    }
891221
protected function createController($controller)
    {
        if (false === strpos($controller, '::')) {
            throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
        }

        list($class, $method) = explode('::', $controller, 2);

        if (!class_exists($class)) {
            throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
        }

        $controller = new $class();
        if ($controller instanceof ContainerAwareInterface) {
            $controller->setContainer($this->container);
        }

        if ($this->container->has('dashboard.view')) {
            $view = $this->container->get('dashboard.view');
            $loader = $view->getLoader();

            if ($path = $this->getViewsPath($controller, $this->container->getParameter('dashboard.widgets_dir'))) {
                $loader->addPath($path);
                $view->setLoader($loader);
                $this->container->set('view', $view);
            }
        }

        return array($controller, $method);
    }