Initializes SanctionComponent for use in the controller

@param object $controller A reference to the instantiating controller object
@return void
496061
public function initialize(Controller $controller) {
		if ($this->settings['isTest']) {
			return;
		}

		$this->user = $this->Session->read("{$this->settings['path']}");

		$this->routes = Permit::$routes;
		Permit::$user = $this->user;

		$this->request = $controller->request;

		foreach (array('controller', 'plugin') as $inflected) {
			if (isset($this->request->params[$inflected])) {
				$this->request->params[$inflected] = strtolower(Inflector::underscore($this->request->params[$inflected]));
			}
		}
	}
167291
public function dispatchAction($controller)
    {
        $action = $this->matchRoute[key($this->matchRoute)]['action'] . 'Action';

        $viewModel = $controller->$action();

        if ($viewModel instanceof ViewModel) {
            $this->view->setVariables($viewModel->getVariables());
        }
    }
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';
				}
			}
		}
	}
68589
public function onControllerInit(BaseController $controller)
    {
        // 除去 admin/login 页面
        if (substr($this->app->getController(), 0, 6) === 'admin/') {
            $controller->middleware(CheckAppStatus::class);
        }

        $this->checkCli();
    }
454446
protected function _authRequired(Controller $controller)
    {
        $request = $controller->getRequest();
        if (is_array($this->_config['requireAuth']) &&
            !empty($this->_config['requireAuth']) &&
            $request->getData()
        ) {
            deprecationWarning('SecurityComponent::requireAuth() will be removed in 4.0.0.');
            $requireAuth = $this->_config['requireAuth'];

            if (in_array($request->getParam('action'), $requireAuth) || $requireAuth == ['*']) {
                if ($request->getData('_Token') === null) {
                    throw new AuthSecurityException('\'_Token\' was not found in request data.');
                }

                if ($this->session->check('_Token')) {
                    $tData = $this->session->read('_Token');

                    if (!empty($tData['allowedControllers']) &&
                        !in_array($request->getParam('controller'), $tData['allowedControllers'])) {
                        throw new AuthSecurityException(
                            sprintf(
                                'Controller \'%s\' was not found in allowed controllers: \'%s\'.',
                                $request->getParam('controller'),
                                implode(', ', (array)$tData['allowedControllers'])
                            )
                        );
                    }
                    if (!empty($tData['allowedActions']) &&
                        !in_array($request->getParam('action'), $tData['allowedActions'])
                    ) {
                        throw new AuthSecurityException(
                            sprintf(
                                'Action \'%s::%s\' was not found in allowed actions: \'%s\'.',
                                $request->getParam('controller'),
                                $request->getParam('action'),
                                implode(', ', (array)$tData['allowedActions'])
                            )
                        );
                    }
                } else {
                    throw new AuthSecurityException('\'_Token\' was not found in session.');
                }
            }
        }

        return true;
    }
823686
protected function _isAllowed(Controller $controller)
    {
        $action = strtolower($controller->getRequest()->getParam('action'));

        return in_array($action, array_map('strtolower', $this->allowedActions));
    }
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;
        }
    }
993351
public static function init($event = null)
    {
        if ($event) {
            self::$_event = $event;
        } else {
            pcntl_signal(SIGALRM, array('\Workerman\Lib\Timer', 'signalHandle'), false);
        }
    }
115290
public function initialize(Controller $controller) {

		parent::initialize($controller);

		$loginUrl = array(
                'plugin' => 'users',
                'controller' => 'users',
                'action' => 'login', 
                'admin' => false, 
                );
        if ( !empty( $controller->request->params['tenant'] ) ) {
            $loginUrl['action'] = 'tenant_login';
        }
        $this->loginAction = $loginUrl;
        $this->logoutRedirect = $loginUrl;
	}
222530
public function prepareController($controller)
    {
        $response   = $this->getResponse();

        if (!$response) {
            $response = new Response();
        }

        $controller->setView($this->getView())
            ->setResponse($response)
            ->setDependencyContainer($this->getDependencyContainer())
            ->setRequest($this->getRequest());
    }
132179
protected function _secureRequired(Controller $controller)
    {
        if (is_array($this->_config['requireSecure']) &&
            !empty($this->_config['requireSecure'])
        ) {
            $requireSecure = $this->_config['requireSecure'];

            if (in_array($this->_action, $requireSecure) || $requireSecure === ['*']) {
                if (!$this->getController()->getRequest()->is('ssl')) {
                    throw new SecurityException(
                        'Request is not SSL and the action is required to be secure'
                    );
                }
            }
        }

        return true;
    }
637874
public static function registerController($controller)
    {
        $uri = '/';

        $routable = (new ControllerInspector)
                            ->getRoutable($controller, $uri);

        // When a controller is routed using this method, we use Reflection to parse
        // out all of the routable methods for the controller, then register each
        // route explicitly for the developers, so reverse routing is possible.
        foreach ($routable as $method => $routes) {
            foreach ($routes as $route) {
                $action = ['uses' => $controller.'@'.$method];

                \Route::{$route['verb']}($route['uri'], $action);
            }
        }

        \Route::any($uri.'/{_missing}', $controller.'@missingMethod');
    }
553048
public function controller($controller = null)
    {
        if (!is_null($controller)) {
            $this->controller = $controller;
            return $this;
        } else {
            return $this->controller ?: '';
        }
    }
873935
public function init($request)
    {
        $this->app->instance('request', $request);
        Facade::clearResolvedInstance('request');
        $this->bootstrap();
    }
78734
public function saveAction(string $controller)
    {
        $this->postAction($controller);
        $this->putAction($controller);
        $this->patchAction($controller);

        return $this;
    }
553558
public function startup(Controller $controller) {
        if ($controller instanceof CakeErrorController) {
            return;
        }

        // Backwards support
        if (isset($this->settings)) {
            $this->_set($this->settings);
        }

        // Detect cookie or login
        $cookie = $this->read();
        $user = $this->Auth->user();

        if (!$this->active || !empty($user) || !$controller->request->is('get')) {
            return;

        } else if ($cookie === null) {
            $this->debug('cookieFail', $this->Cookie, $user);
            $this->delete();
            return;

        } else if (empty($cookie['hash']) || $cookie['hash'] !== $this->Auth->password($cookie['username'] . $cookie['time'])) {
            $this->debug('hashFail', $this->Cookie, $user);
            $this->delete();
            return;
        }

        // Set the data to identify with
        $controller->request->data[$this->model][$this->username] = $cookie['username'];
        $controller->request->data[$this->model][$this->password] = $cookie['password'];

        if ($this->Auth->login()) {
            $this->debug('login', $this->Cookie, $this->Auth->user());

            if (in_array('_autoLogin', get_class_methods($controller))) {
                call_user_func(array($controller, '_autoLogin'), $this->Auth->user());
            }

            if ($this->redirect) {
                $controller->redirect($controller->referer($this->Auth->redirect()), 302);
            }
        } else {
            $this->debug('loginFail', $this->Cookie, $this->Auth->user());

            if (in_array('_autoLoginError', get_class_methods($controller))) {
                call_user_func(array($controller, '_autoLoginError'), $this->read());
            }
        }
    }
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']
                                          );
        }
    }