Commit 771b6ddf authored by dawehner's avatar dawehner Committed by tim.plunkett

Issue #1760472 by dawehner | slv_: Fixed HttpKernel error when trying to get...

Issue #1760472 by dawehner | slv_: Fixed HttpKernel error when trying to get comments_recent() default view.
parent 3f892c2d
......@@ -33,7 +33,7 @@ abstract class DisplayPluginBase extends PluginBase {
/**
* The top object of a view.
*
* @var view
* @var Drupal\views\View
*/
var $view = NULL;
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\display;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
......@@ -66,7 +67,7 @@ function get_style_type() { return 'feed'; }
function execute() {
$output = $this->view->render();
if (empty($output)) {
return drupal_not_found();
throw new NotFoundHttpException();
}
$response = $this->view->getResponse();
......
......@@ -8,6 +8,8 @@
namespace Drupal\views\Plugin\views\display;
use Drupal\Core\Annotation\Plugin;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Core\Annotation\Translation;
/**
......@@ -238,11 +240,11 @@ function execute() {
// display, and arguments should be set on the view.
$this->view->build();
if (!empty($this->view->build_info['fail'])) {
return drupal_not_found();
throw new NotFoundHttpException();
}
if (!empty($this->view->build_info['denied'])) {
return drupal_access_denied();
throw new AccessDeniedHttpException();
}
$this->view->get_breadcrumb(TRUE);
......
<?php
/**
* @file
* Definition of Drupal\views\Tests\Plugin\DisplayPageTest.
*/
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Tests\Plugin\PluginTestBase;
/**
* Tests the page display plugin.
*
* @see Drupal\views\Plugin\display\Page
*/
class DisplayPageTest extends PluginTestBase {
public static function getInfo() {
return array(
'name' => 'Display: Page plugin',
'description' => 'Tests the page display plugin.',
'group' => 'Views Plugins',
);
}
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
}
/**
* Checks the behavior of the page for access denied/not found behaviours.
*/
public function testPageResponses() {
$view = views_get_view('test_page_display');
$this->drupalGet('test_page_display_403');
$this->assertResponse(403);
$this->drupalGet('test_page_display_404');
$this->assertResponse(404);
}
}
api_version: '2'
base_table: node
core: { }
description: ''
disabled: '0'
display:
default:
display_options:
access:
type: none
cache:
type: none
display_plugin: default
display_title: Master
id: default
position: '0'
page_1:
display_options:
path: test_page_display_403
display_plugin: page
display_title: Page
id: page_1
position: '0'
page_2:
display_options:
path: test_page_display_404
display_plugin: page
display_title: Page
id: page_2
position: '0'
human_name: { }
name: test_page_display
tag: ''
\ No newline at end of file
......@@ -52,3 +52,18 @@ function views_test_views_pre_render(&$view) {
$view->pre_render_called = TRUE;
}
}
/**
* Implements hook_views_post_build().
*/
function views_test_views_post_build(Drupal\views\View &$view) {
debug($view->current_display);
if ($view->name == 'test_page_display') {
if ($view->current_display == 'page_1') {
$view->build_info['denied'] = TRUE;
}
elseif ($view->current_display == 'page_2') {
$view->build_info['fail'] = TRUE;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment