Skip to content

Commit

Permalink
Fix deprecation failures for RequestHandlerComponent.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 16, 2017
1 parent b759fa6 commit e09e3ec
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 137 deletions.
7 changes: 5 additions & 2 deletions src/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -331,14 +331,17 @@ public function beforeRender(Event $event)
if ($this->ext && $isRecognized) {
$this->renderAs($controller, $this->ext);
} else {
$controller->response = $response->withCharset(Configure::read('App.encoding'));
$response = $response->withCharset(Configure::read('App.encoding'));
}

if ($this->_config['checkHttpCache'] &&
$response->checkNotModified($request)
) {
$controller->response = $response;

return false;
}
$controller->response = $response;
}

/**
Expand Down Expand Up @@ -675,7 +678,7 @@ public function responseType()
{
$response = $this->getController()->response;

return $response->mapType($response->type());
return $response->mapType($response->getType());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Response.php
Expand Up @@ -1685,7 +1685,7 @@ public function notModified()
'Last-Modified'
];
foreach ($remove as $header) {
unset($this->headers[$header]);
$this->_clearHeader($header);
}
}

Expand Down Expand Up @@ -1991,7 +1991,7 @@ public function checkNotModified(ServerRequest $request)

$modifiedSince = $request->getHeaderLine('If-Modified-Since');
if ($modifiedSince && $this->hasHeader('Last-Modified')) {
$timeMatches = strtotime($this->getHeaderLine('Last-Modifed')) === strtotime($modifiedSince);
$timeMatches = strtotime($this->getHeaderLine('Last-Modified')) === strtotime($modifiedSince);
}
$checks = compact('etagMatches', 'timeMatches');
if (empty($checks)) {
Expand Down
6 changes: 3 additions & 3 deletions src/View/AjaxView.php
Expand Up @@ -46,10 +46,10 @@ public function __construct(
EventManager $eventManager = null,
array $viewOptions = []
) {
parent::__construct($request, $response, $eventManager, $viewOptions);

if ($response && $response instanceof Response) {
$response->type('ajax');
$response = $response->withType('ajax');
}

parent::__construct($request, $response, $eventManager, $viewOptions);
}
}

0 comments on commit e09e3ec

Please sign in to comment.