/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Controller
NameSizeModeActions
Component/-0755rm
Exception/-0755rm
Component.php65040644editdlrm
ComponentRegistry.php44480644editdlrm
Controller.php276140644editdlrm
ControllerFactory.php60370644editdlrm
ErrorController.php16990644editdlrm
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Controller/ControllerFactory.php (6037B)
*/ class ControllerFactory implements ControllerFactoryInterface { /** * Create a controller for a given request. * * @param \Psr\Http\Message\ServerRequestInterface $request The request to build a controller for. * @return \Cake\Controller\Controller * @throws \Cake\Http\Exception\MissingControllerException */ public function create(ServerRequestInterface $request): Controller { $className = $this->getControllerClass($request); if ($className === null) { $this->missingController($request); } /** @psalm-suppress PossiblyNullArgument */ $reflection = new ReflectionClass($className); if ($reflection->isAbstract()) { $this->missingController($request); } /** @var \Cake\Controller\Controller $controller */ $controller = $reflection->newInstance($request); return $controller; } /** * Invoke a controller's action and wrapping methods. * * @param mixed $controller The controller to invoke. * @return \Psr\Http\Message\ResponseInterface The response * @throws \Cake\Controller\Exception\MissingActionException If controller action is not found. * @throws \UnexpectedValueException If return value of action method is not null or ResponseInterface instance. * @psalm-param \Cake\Controller\Controller $controller */ public function invoke($controller): ResponseInterface { $result = $controller->startupProcess(); if ($result instanceof ResponseInterface) { return $result; } $action = $controller->getAction(); $args = array_values($controller->getRequest()->getParam('pass')); $controller->invokeAction($action, $args); $result = $controller->shutdownProcess(); if ($result instanceof ResponseInterface) { return $result; } return $controller->getResponse(); } /** * Determine the controller class name based on current request and controller param * * @param \Cake\Http\ServerRequest $request The request to build a controller for. * @return string|null * @psalm-return class-string<\Cake\Controller\Controller>|null */ public function getControllerClass(ServerRequest $request): ?string { $pluginPath = ''; $namespace = 'Controller'; $controller = $request->getParam('controller', ''); if ($request->getParam('plugin')) { $pluginPath = $request->getParam('plugin') . '.'; } if ($request->getParam('prefix')) { $prefix = $request->getParam('prefix'); $firstChar = substr($prefix, 0, 1); if ($firstChar !== strtoupper($firstChar)) { deprecationWarning( "The `{$prefix}` prefix did not start with an upper case character. " . 'Routing prefixes should be defined as CamelCase values. ' . 'Prefix inflection will be removed in 5.0' ); if (strpos($prefix, '/') === false) { $namespace .= '/' . Inflector::camelize($prefix); } else { $prefixes = array_map( function ($val) { return Inflector::camelize($val); }, explode('/', $prefix) ); $namespace .= '/' . implode('/', $prefixes); } } else { $namespace .= '/' . $prefix; } } $firstChar = substr($controller, 0, 1); // Disallow plugin short forms, / and \\ from // controller names as they allow direct references to // be created. if ( strpos($controller, '\\') !== false || strpos($controller, '/') !== false || strpos($controller, '.') !== false || $firstChar === strtolower($firstChar) ) { $this->missingController($request); } // phpcs:ignore SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat /** @var class-string<\Cake\Controller\Controller>|null */ return App::className($pluginPath . $controller, $namespace, 'Controller'); } /** * Throws an exception when a controller is missing. * * @param \Cake\Http\ServerRequest $request The request. * @throws \Cake\Http\Exception\MissingControllerException * @return void */ protected function missingController(ServerRequest $request): void { throw new MissingControllerException([ 'class' => $request->getParam('controller'), 'plugin' => $request->getParam('plugin'), 'prefix' => $request->getParam('prefix'), '_ext' => $request->getParam('_ext'), ]); } }