Skip to content
Permalink
Browse files

Fix silencing errors in extension handling.

  • Loading branch information...
dereuromark committed Sep 23, 2018
1 parent 4feee54 commit fb720c7e605fc31c90b4fbbcd2b527817f6628c8
Showing with 25 additions and 2 deletions.
  1. +8 −1 src/Controller/Component/RequestHandlerComponent.php
  2. +17 −1 src/Http/Response.php
@@ -21,6 +21,7 @@
use Cake\Core\Configure;
use Cake\Core\Exception\Exception;
use Cake\Event\Event;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Response;
use Cake\Routing\Router;
use Cake\Utility\Exception\XmlException;
@@ -332,8 +333,11 @@ public function beforeRender(Event $event)
!in_array($this->ext, ['html', 'htm']) &&
$response->getMimeType($this->ext)
);
if ($this->ext && !$isRecognized) {
throw new NotFoundException('Invoked extension not recognized: ' . $this->ext);
}
if ($this->ext && $isRecognized) {
if ($this->ext) {
$this->renderAs($controller, $this->ext);
$response = $controller->response;
} else {
@@ -594,6 +598,9 @@ public function renderAs(Controller $controller, $type, array $options = [])
$viewClass = null;
if ($builder->getClassName() === null) {
$viewClass = App::className($view, 'View', 'View');
if ($viewClass === false) {
throw new RuntimeException('Configured view class can not be found: ' . $view);
}
}
if ($viewClass) {
@@ -1111,7 +1111,7 @@ public function type($contentType = null)
{
deprecationWarning(
'Response::type() is deprecated. ' .
'Use getType() or withType() instead.'
'Use getType(), setType() or withType() instead.'
);
if ($contentType === null) {
@@ -1137,6 +1137,22 @@ public function type($contentType = null)
return $contentType;
}
/**
* Sets a content type into the map.
*
* E.g.: setType('xhtml' => ['application/xhtml+xml', 'application/xhtml', 'text/xhtml'])
*
* This is needed for RequestHandlerComponent and recognition of types.
*
* @param string $type
* @param string|array $definition
* @return void
*/
public function setType($type, $definition)
{
$this->_mimeTypes[$type] = $definition;
}
/**
* Returns the current content type.
*

0 comments on commit fb720c7

Please sign in to comment.
You can’t perform that action at this time.