diff --git a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php
index 6e65758..a8b01a3 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php
@@ -289,26 +289,6 @@ public function &getDisplay($display_id) {
}
/**
- * Gets a list of displays included in the view.
- *
- * @return array
- * An array of display types that this view includes.
- */
- function getDisplaysList() {
- $manager = Views::pluginManager('display');
- $displays = array();
- foreach ($this->display as $display) {
- $definition = $manager->getDefinition($display['display_plugin']);
- if (!empty($definition['admin'])) {
- $displays[$definition['admin']] = TRUE;
- }
- }
-
- ksort($displays);
- return array_keys($displays);
- }
-
- /**
* Gets a list of paths assigned to the view.
*
* @return array
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php
index 6a86adf..97ec65d 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php
@@ -219,8 +219,6 @@ protected function displayMethodTests() {
);
$view = $this->controller->create($config);
- $this->assertEqual($view->getDisplaysList(), array('Feed', 'Page'), 'Make sure the display admin names are returns in alphabetic order.');
-
// Paths with a "%" shouldn't not be linked
$expected_paths = array();
$expected_paths[] = l('/test', 'test');
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php
index 7bb130e..763cf24 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php
@@ -7,13 +7,55 @@
namespace Drupal\views_ui;
+use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityListController;
+use Drupal\Core\Entity\EntityControllerInterface;
+use Drupal\Core\Entity\EntityStorageControllerInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a listing of Views.
*/
-class ViewListController extends ConfigEntityListController {
+class ViewListController extends ConfigEntityListController implements EntityControllerInterface {
+
+ /**
+ * The views display plugin manager to use.
+ *
+ * @var \Drupal\Component\Plugin\PluginManagerInterface
+ */
+ protected $displayManager;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) {
+ return new static(
+ $entity_type,
+ $container->get('plugin.manager.entity')->getStorageController($entity_type),
+ $entity_info,
+ $container->get('plugin.manager.views.display')
+ );
+ }
+
+ /**
+ * Constructs a new EntityListController object.
+ *
+ * @param string $entity_type.
+ * The type of entity to be listed.
+ * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage.
+ * The entity storage controller class.
+ * @param array $entity_info
+ * An array of entity info for this entity type.
+ * @param \Drupal\Component\Plugin\PluginManagerInterface $display_manager
+ * The views display plugin manager to use.
+ */
+ public function __construct($entity_type, EntityStorageControllerInterface $storage, $entity_info, PluginManagerInterface $display_manager) {
+ $this->entityType = $entity_type;
+ $this->storage = $storage;
+ $this->entityInfo = $entity_info;
+ $this->displayManager = $display_manager;
+ }
/**
* Overrides Drupal\Core\Entity\EntityListController::load();
@@ -40,7 +82,11 @@ public function load() {
public function buildRow(EntityInterface $view) {
return array(
'data' => array(
- 'view_name' => theme('views_ui_view_info', array('view' => $view)),
+ 'view_name' => array(
+ '#theme' => 'views_ui_view_info',
+ '#view' => $view,
+ '#displays' => $this->getDisplaysList($view)
+ ),
'description' => $view->get('description'),
'tag' => $view->get('tag'),
'path' => implode(', ', $view->getPaths()),
@@ -156,4 +202,26 @@ public function render() {
return $list;
}
+ /**
+ * Gets a list of displays included in the view.
+ *
+ * @param \Drupal\Core\Entity\EntityInterface $view
+ * The view entity instance to get a list of displays for.
+ *
+ * @return array
+ * An array of display types that this view includes.
+ */
+ protected function getDisplaysList(EntityInterface $view) {
+ $displays = array();
+ foreach ($view->get('display') as $display) {
+ $definition = $this->displayManager->getDefinition($display['display_plugin']);
+ if (!empty($definition['admin'])) {
+ $displays[$definition['admin']] = TRUE;
+ }
+ }
+
+ ksort($displays);
+ return array_keys($displays);
+ }
+
}
diff --git a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php
new file mode 100644
index 0000000..61fa474
--- /dev/null
+++ b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php
@@ -0,0 +1,110 @@
+ 'Views List Controller Unit Test',
+ 'description' => 'Unit tests the views list controller',
+ 'group' => 'Views UI',
+ );
+ }
+
+ /**
+ * Tests the listing of displays on a views list.
+ *
+ * @see \Drupal\views_ui\ViewListController::getDisplaysList().
+ */
+ public function testBuildRowEntityList() {
+ $storage_controller = $this->getMockBuilder('Drupal\views\ViewStorageController')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $entity_info = array();
+ $display_manager = $this->getMockBuilder('\Drupal\views\Plugin\ViewsPluginManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $display_manager->expects($this->any())
+ ->method('getDefinition')
+ ->will($this->returnValueMap(array(
+ array(
+ 'default',
+ array(
+ 'id' => 'default',
+ 'title' => 'Master',
+ 'theme' => 'views_view',
+ 'no_ui' => TRUE,
+ )
+ ),
+ array(
+ 'page',
+ array(
+ 'id' => 'page',
+ 'title' => 'Page',
+ 'uses_hook_menu' => TRUE,
+ 'uses_route' => TRUE,
+ 'contextual_links_locations' => array('page'),
+ 'theme' => 'views_view',
+ 'admin' => 'Page admin label',
+ )
+ ),
+ array(
+ 'embed',
+ array(
+ 'id' => 'embed',
+ 'title' => 'embed',
+ 'theme' => 'views_view',
+ 'admin' => 'Embed admin label',
+ )
+ ),
+ )));
+
+ // Setup a view list controller with a mocked buildOperations method,
+ // because t() is called on there.
+ $view_list_controller = $this->getMock('Drupal\views_ui\ViewListController', array('buildOperations'), array('view', $storage_controller, $entity_info, $display_manager));
+ $view_list_controller->expects($this->any())
+ ->method('buildOperations')
+ ->will($this->returnValue(array()));
+
+ $values = array();
+ $values['display']['default']['id'] = 'default';
+ $values['display']['default']['display_title'] = 'Display';
+ $values['display']['default']['display_plugin'] = 'default';
+
+ $values['display']['page_1']['id'] = 'page_1';
+ $values['display']['page_1']['display_title'] = 'Page 1';
+ $values['display']['page_1']['display_plugin'] = 'page';
+
+ $values['display']['embed']['id'] = 'embed';
+ $values['display']['embed']['display_title'] = 'Embedded';
+ $values['display']['embed']['display_plugin'] = 'embed';
+
+ $view = new View($values, 'view');
+
+ $row = $view_list_controller->buildRow($view);
+
+ $this->assertEquals(array('Embed admin label', 'Page admin label'), $row['data']['view_name']['#displays'], 'Wrong displays got added to view list');
+ }
+}
+
+}
+
+// @todo Remove this once t() is converted to a service.
+namespace {
+ if (!function_exists('t')) {
+ function t($string) {
+ return $string;
+ }
+ }
+}
diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module
index 21fdabe..343627e 100644
--- a/core/modules/views_ui/views_ui.module
+++ b/core/modules/views_ui/views_ui.module
@@ -154,7 +154,7 @@ function views_ui_theme() {
// list views
'views_ui_view_info' => array(
- 'variables' => array('view' => NULL, 'base' => NULL),
+ 'variables' => array('view' => NULL, 'displays' => NULL),
'file' => 'views_ui.theme.inc',
),
diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc
index 1980149..8e503fc 100644
--- a/core/modules/views_ui/views_ui.theme.inc
+++ b/core/modules/views_ui/views_ui.theme.inc
@@ -93,9 +93,7 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) {
*/
function template_preprocess_views_ui_view_info(&$variables) {
$variables['title'] = $variables['view']->label();
-
- $displays = $variables['view']->getDisplaysList();
- $variables['displays'] = empty($displays) ? t('None') : format_plural(count($displays), 'Display', 'Displays') . ': ' . '' . implode(', ', $displays) . '';
+ $variables['displays'] = empty($variables['displays']) ? t('None') : format_plural(count($variables['displays']), 'Display', 'Displays') . ': ' . '' . implode(', ', $variables['displays']) . '';
}
/**