summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-11-03 11:56:22 (GMT)
committerAlex Pott2015-11-03 11:56:22 (GMT)
commitd46772889b31abde25b2c610c6a5f802d95e238f (patch)
tree1a7a9b6ddad2bc881573c9433894dd157a0de05b
parent65dd859920f6e17f5cb9737f2e43796298bad93f (diff)
Issue #2516742 by DuaelFr, dawehner: Allow Views to be resolved by TitleResolver
-rw-r--r--core/modules/rest/tests/src/Unit/CollectRoutesTest.php5
-rw-r--r--core/modules/views/src/Plugin/views/display/PathPluginBase.php1
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php14
3 files changed, 19 insertions, 1 deletions
diff --git a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
index c49ff87..8b5d215 100644
--- a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
+++ b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
@@ -49,7 +49,10 @@ class CollectRoutesTest extends UnitTestCase {
'view',
));
- $view_executable = $this->getMock('\Drupal\views\ViewExecutable', array('initHandlers'), array(), '', FALSE);
+ $view_executable = $this->getMock('\Drupal\views\ViewExecutable', array('initHandlers', 'getTitle'), array(), '', FALSE);
+ $view_executable->expects($this->any())
+ ->method('getTitle')
+ ->willReturn('View title');
$view_executable->storage = $this->view;
$view_executable->argument = array();
diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
index 4df46bc..738fbf4 100644
--- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
@@ -134,6 +134,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
protected function getRoute($view_id, $display_id) {
$defaults = array(
'_controller' => 'Drupal\views\Routing\ViewPageController::handle',
+ '_title' => $this->view->getTitle(),
'view_id' => $view_id,
'display_id' => $display_id,
'_view_display_show_admin_links' => $this->getOption('show_admin_links'),
diff --git a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
index b0ebe13..bae789a 100644
--- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
@@ -108,6 +108,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertSame(FALSE, $route->getOption('returns_response'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -134,6 +135,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->pathPlugin->collectRoutes($collection);
$route = $collection->get('view.test_id.page_1');
$this->assertSame(TRUE, $route->getOption('returns_response'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -161,6 +163,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals(array('arg_0' => 'arg_0'), $route->getOption('_view_argument_map'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -191,6 +194,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals(array('arg_0' => 'arg_0'), $route->getOption('_view_argument_map'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -216,6 +220,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertTrue($route instanceof Route);
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -245,6 +250,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertTrue($route instanceof Route);
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
// Ensure that the test_route_2 is not overridden.
$route = $collection->get('test_route_2');
@@ -285,6 +291,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertEquals('/test_route/{node}/example', $route->getPath());
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
$this->assertEquals(array('arg_0' => 'node'), $route->getOption('_view_argument_map'));
}
@@ -322,6 +329,7 @@ class PathPluginBaseTest extends UnitTestCase {
// Ensure that the path did not changed and placeholders are respected.
$this->assertEquals('/test_route/{parameter}', $route->getPath());
$this->assertEquals(array('arg_0' => 'parameter'), $route->getOption('_view_argument_map'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -359,6 +367,7 @@ class PathPluginBaseTest extends UnitTestCase {
// Ensure that the path did not changed and placeholders are respected kk.
$this->assertEquals('/test_route/{parameter}', $route->getPath());
$this->assertEquals(['arg_0' => 'parameter'], $route->getOption('_view_argument_map'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -393,6 +402,7 @@ class PathPluginBaseTest extends UnitTestCase {
// Ensure that the path did not changed and placeholders are respected.
$this->assertEquals('/test_route/{parameter}/{arg_1}', $route->getPath());
$this->assertEquals(array('arg_0' => 'parameter'), $route->getOption('_view_argument_map'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
@@ -427,6 +437,10 @@ class PathPluginBaseTest extends UnitTestCase {
$view = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
->getMock();
+ $view->expects($this->any())
+ ->method('getTitle')
+ ->willReturn('my views title');
+
$view->storage = $view_entity;
// Skip views options caching.