/** * * @param ServerRequestInterface $request A server request object * @param ResponseInterface $response A response object * @param callable $next The next middleware to be executed * @return mixed */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next) { // Convert the request/response to CakePHP equivalents. $cakeRequest = RequestTransformer::toCake($request); $cakeResponse = ResponseTransformer::toCake($response); // Dispatch the request/response to CakePHP $cakeResponse = $this->getDispatcher()->dispatch($cakeRequest, $cakeResponse); // Convert the response back into a PSR7 object. return $next($request, ResponseTransformer::toPsr($cakeResponse)); }
public function testToCakeBaseSessionPath() { Configure::write('App.baseUrl', false); $server = ['DOCUMENT_ROOT' => '/cake/repo/branches', 'PHP_SELF' => '/thisapp/webroot/index.php', 'REQUEST_URI' => '/posts/view/1']; $psr = ServerRequestFactory::fromGlobals($server); $cake = RequestTransformer::toCake($psr); $this->assertEquals('/thisapp', ini_get('session.cookie_path')); }