An action or view is being overridden, so prepare the layout and environment.
Bind any other data that should be present.

@param Controller $controller
976983
public function beforeRender(Controller $controller) {
        $badges = array();

        foreach (Configure::read('Admin.menu') as $section => $menu) {
            $badges[$section] = $menu['count'];
        }

        $controller->set('badgeCounts', $badges);

        if (isset($controller->Model)) {
            $controller->set('model', $controller->Model);
        }

        if (isset($controller->request->params['override'])) {
            $controller->layout = 'Admin.admin';
            $controller->request->params['action'] = str_replace('admin_', '', $controller->action);
        }
    }
535339
public static function execute($controller, $request) {   
        switch($request->method()) { 
            case 'POST':
                $data = $controller->store($request->bodyRequest());
                KernelHttp::makeResponse('201', $data);
                break;
            case 'PUT':
                $data = $controller->update($request->bodyRequest());
                KernelHttp::makeResponse('200', $data);
                break;
            case 'DELETE':
                $controller->destroy($request->getInteractionsRequest());
                KernelHttp::makeResponse('200');
                break;
            default: 
                $request->getRequiredParameter() ? $data = $controller->show($request->getInteractionsRequest()) : $data = $controller->index($request->getInteractionsRequest()); 
                KernelHttp::makeResponse('200', $data);
                break;
        } 
    }
575204
public function beforeRender(Controller $controller) {
		$configs = Cache::configured();
		$content = array();

		if (method_exists('Cache', 'getLogs')) {
			$content['stats'] = Cache::getLogs();
		}

		foreach($configs as $config)
		{
			$engine = Cache::settings($config);

			if (method_exists('Cache', 'getLogs')) {
				$logs = Cache::getLogs($config);
			} else {
				$logs['logs'] = array();
			}

			$content['cache'][$config] = array('settings' => $engine, 'logs' => $logs['logs']);
		}

		ksort($content['cache']);

		if ($this->priority > 0 && isset($content['stats'])) {
			if ($content['stats']['count'] === 0) {
				$this->title = __d('debug_kit_ex', '<b>0</b> cache');
			} else {
				$this->title = __d('debug_kit_ex', '<b>%dms / %d</b> cache', round($content['stats']['time']), $content['stats']['count']['total']);
			}
		}

		return $content;
	}
690855
protected function setModuleAssets($controller)
    {
        if (!$controller->isInternalRoute()) {

            $settings = $this->module->getSettings('dev');

            if (!empty($settings['status'])) {
                $controller->setJsSettings('dev', array('key' => $settings['key']));
                $controller->setJs(__DIR__ . '/js/common.js', array('position' => 'bottom'));
                $controller->setCss(__DIR__ . '/css/common.css');
            }
        }
    }
469663
private function callControllerMethod(Controller $controller, $method)
    {
        return app()->call([$controller, $method], ParameterBag::getParameters());
    }
60368
final public function forward(string $controller, $action = null) :void {

		// get the current route as a base
		$route = Router::getCurrentRoute();
		
		// and alter it
		$route->controller	= $controller;
		$route->action		= $action;
		
		// forward to the new route
		Router::forward($route);
		
	}
98361
protected function setDevToolbar(&$html, $controller)
    {
        if (!$controller->isInternalRoute()) {

            $settings = $this->module->getSettings('dev');

            if (!empty($settings['status'])) {

                $data = array(
                    'key' => $settings['key'],
                    'time' => microtime(true) - GC_START,
                    'queries' => $this->db->getExecutedQueries()
                );

                $toolbar = $controller->render('dev|toolbar', $data);
                $html = substr_replace($html, $toolbar, strpos($html, '</body>'), 0);
            }
        }
    }
510642
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('CakeTheme.ViewExtension')) {
			$this->_controller->ViewExtension = $this->_controller->Components->load('CakeTheme.ViewExtension');
			$this->_controller->ViewExtension->initialize($this->_controller);
		}
	}
1050550
protected function _setConfigVar(Controller &$controller) {
		$additionalCssFiles = $this->_modelConfigTheme->getListCssFiles();
		$additionalJsFiles = $this->_modelConfigTheme->getListJsFiles();
		$controller->set(compact('additionalCssFiles', 'additionalJsFiles'));
	}
351590
public function hookTheme(Controller $controller)
    {
        if ($controller->isCurrentTheme('backend') && !$controller->isInternalRoute()) {
            $this->setAssets($controller);
            $this->setMetaTags($controller);
        }
    }
500036
public function beforeRender(Controller $controller) {
		if (empty($controller->Permit->user)) {
			$controller->Permit->user = $controller->Toolbar->Session->read($controller->Permit->settings['path']);
		}
		return array(
			'user' => $controller->Permit->user,
			'routes' => $controller->Permit->routes,
			'executed' => $controller->Permit->executed,
		);
	}
146695
public function handleController(
        $controller, $action = null, array $params = null, $model = null
    ) {

        ! $model || $model = $this->modelFactory->create(null, $model);

        $this->setController(
            $this->controllerFactory->create($params, $controller, $model)
        );

        if (!is_null($action)) {
            $this->setControllerResult(
                $this->executeMethod($this->getController(), $action, $params, $model)
            );
        }
    }
1292971
protected function implements(String & $controller)
    {
        if( ! empty($this->settings['implements']) )
        {
            $controller .= " implements ".( is_array($this->settings['implements'])
                                            ? implode(', ', $this->settings['implements'])
                                            : $this->settings['implements']
                                          );
        }
    }
648057
final public function setView($controller, $action)
    {
        $this->view = new View($controller, $action);
        // To maintain compatibility with version 1.0
        $this->View = $this->view;
        // If Layout is enable, send new view to it
        if (isset($this->layout)) {
            $this->layout->setView($this->view);
            // To maintain compatibility with version 1.0
            $this->Layout = $this->layout;
        }
    }
508856
function(controller, callback) {
            self.prepareControllerActions(controller, function(err, actions) {
                callback(err, controller, actions);
            });
        }
751070
protected function setControllerVars($controller)
    {
        $this->controller = $controller;

        if (is_callable($controller)) {
            $this->setControllerCallable($controller);
        } else {
            $this->usesCallable = false;
            $atCharPos = strpos($controller, '@');

            // Make sure the "@" is somewhere in the middle of the string
            if ($atCharPos === false || $atCharPos === 0 || $atCharPos === mb_strlen($controller) - 1) {
                throw new InvalidArgumentException('Controller string is not formatted correctly');
            }

            $this->controllerName = substr($controller, 0, $atCharPos);
            $this->controllerMethod = substr($controller, $atCharPos + 1);
        }
    }
856367
public function runController($controller = null, $action = null, $values = array())
    {
        if($action != null && method_exists($controller, $action))
        {
            if($values != null)
            {
                call_user_func_array(array($controller, $action), $values);
            }
            else
            {
                $controller->{$action}();
            }
        }
        else
        {
            $controller;
        }
    }