APP/Controller/PagesController.php at line 75
(edit)
|
} catch (MissingTemplateException $exception) {
|
|
if (Configure::read('debug')) {
|
|
throw $exception;
|
|
}
|
|
throw new NotFoundException();
|
|
}
|
|
|
|
return $this->render();
|
|
}
|
-
|
* @throws \UnexpectedValueException If return value of action is not `null` or `ResponseInterface` instance.
|
|
*/
|
|
public function invokeAction(Closure $action, array $args): void
|
|
{
|
|
$result = $action(...$args);
|
|
if ($result !== null && !$result instanceof ResponseInterface) {
|
|
throw new UnexpectedValueException(sprintf(
|
|
'Controller actions can only return ResponseInterface instance or null. '
|
|
. 'Got %s instead.',
|
Toggle Arguments
-
|
$args = $this->getActionArgs(
|
|
$action,
|
|
array_values((array)$controller->getRequest()->getParam('pass'))
|
|
);
|
|
$controller->invokeAction($action, $args);
|
|
|
|
$result = $controller->shutdownProcess();
|
|
if ($result instanceof ResponseInterface) {
|
|
return $result;
|
Toggle Arguments
-
|
|
|
return $runner->run($middlewareQueue, $controller->getRequest(), $this);
|
|
}
|
|
|
|
return $this->handle($controller->getRequest());
|
|
}
|
|
|
|
/**
|
|
* Invoke the action.
|
Toggle Arguments
-
|
|
|
// This is needed for auto-wiring. Should be removed in 5.x
|
|
$container->add(ComponentRegistry::class, $controller->components());
|
|
|
|
return $this->controllerFactory->invoke($controller);
|
|
}
|
|
}
|
|
|
Toggle Arguments
-
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
|
}
|
|
|
|
return new Response([
|
|
'body' => 'Middleware queue was exhausted without returning a response '
|
Toggle Arguments
-
|
if ($request->getCookieParams()) {
|
|
$request = $this->decodeCookies($request);
|
|
}
|
|
|
|
$response = $handler->handle($request);
|
|
if ($response->hasHeader('Set-Cookie')) {
|
|
$response = $this->encodeSetCookieHeader($response);
|
|
}
|
|
if ($response instanceof Response) {
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
$request = $request->withAttribute($attribute, $identity);
|
|
}
|
|
|
|
try {
|
|
$response = $handler->handle($request);
|
|
|
|
if ($this->getConfig('requireAuthorizationCheck') && !$service->authorizationChecked()) {
|
|
throw new AuthorizationRequiredException(['url' => $request->getRequestTarget()]);
|
|
}
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
$request = $request->withAttribute('authentication', $service);
|
|
$request = $request->withAttribute('authenticationResult', $result);
|
|
|
|
try {
|
|
$response = $handler->handle($request);
|
|
$authenticator = $service->getAuthenticationProvider();
|
|
|
|
if ($authenticator !== null && !$authenticator instanceof StatelessInterface) {
|
|
$return = $service->persistIdentity($request, $response, $result->getData());
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
Hash::get($params, 'plugin') !== 'ADmad/SocialAuth'
|
|
|| Hash::get($params, 'controller') !== 'Auth'
|
|
|| !in_array($action, ['login', 'callback'], true)
|
|
) {
|
|
return $handler->handle($request);
|
|
}
|
|
|
|
$method = '_handle' . ucfirst($action) . 'Action';
|
|
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
}
|
|
|
|
Configure::write('App.language', $lang);
|
|
|
|
return $handler->handle($request);
|
|
}
|
|
|
|
/**
|
|
* Set closure for deciding whether or not to ignore particular request.
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
);
|
|
}
|
|
$matching = Router::getRouteCollection()->getMiddleware($middleware);
|
|
if (!$matching) {
|
|
return $handler->handle($request);
|
|
}
|
|
|
|
$container = $this->app instanceof ContainerApplicationInterface
|
|
? $this->app->getContainer()
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
|
{
|
|
$url = $request->getUri()->getPath();
|
|
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
|
|
return $handler->handle($request);
|
|
}
|
|
|
|
if (strpos($url, '/.') !== false) {
|
|
return $handler->handle($request);
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
*/
|
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
|
{
|
|
try {
|
|
return $handler->handle($request);
|
|
} catch (RedirectException $exception) {
|
|
return $this->handleRedirect($exception);
|
|
} catch (Throwable $exception) {
|
|
return $this->handleException($exception, $request);
|
Toggle Arguments
-
|
if ($this->queue->valid()) {
|
|
$middleware = $this->queue->current();
|
|
$this->queue->next();
|
|
|
|
return $middleware->process($request, $this);
|
|
}
|
|
|
|
if ($this->fallbackHandler) {
|
|
return $this->fallbackHandler->handle($request);
|
Toggle Arguments
-
|
) {
|
|
Router::setRequest($request);
|
|
}
|
|
|
|
return $this->handle($request);
|
|
}
|
|
|
|
/**
|
|
* Handle incoming server request and return a response.
|
Toggle Arguments
-
|
}
|
|
|
|
$this->dispatchEvent('Server.buildMiddleware', ['middleware' => $middleware]);
|
|
|
|
$response = $this->runner->run($middleware, $request, $this->app);
|
|
|
|
if ($request instanceof ServerRequest) {
|
|
$request->getSession()->close();
|
|
}
|
Toggle Arguments
-
|
// Bind your application to the server.
|
|
$server = new Server(new Application(dirname(__DIR__) . '/config'));
|
|
|
|
// Run the request/response through the application and emit the response.
|
|
$server->emit($server->run());
|
|
|
Toggle Arguments
-
If you want to customize this error message, create
templates/Error/error400.ctp