From ec25fec7ea0f5b2e33cfbb1fcbc4b17a373fc37f Mon Sep 17 00:00:00 2001 From: damiankloip Date: Wed, 19 Sep 2012 09:23:37 +0200 Subject: [PATCH] Issue #1787270 by damiankloip | dawehner: Fixed Split up default views into one per module. --- config/views.view.archive.yml | 1 + config/views.view.backlinks.yml | 1 + config/views.view.comments_recent.yml | 1 + config/views.view.frontpage.yml | 1 + config/views.view.glossary.yml | 1 + config/views.view.taxonomy_term.yml | 1 + config/views.view.tracker.yml | 1 + lib/Drupal/views/Tests/ViewStorageTest.php | 3 ++- lib/Drupal/views/ViewStorage.php | 14 ++++++++++++++ lib/Drupal/views/ViewStorageController.php | 16 ++++++++++++++++ 10 files changed, 39 insertions(+), 1 deletion(-) diff --git a/config/views.view.archive.yml b/config/views.view.archive.yml index b9d4810dfd72..6e783bd16682 100644 --- a/config/views.view.archive.yml +++ b/config/views.view.archive.yml @@ -1,5 +1,6 @@ disabled: true api_version: '3.0' +module: node name: archive description: 'Display a list of months that link to content for that month.' tag: default diff --git a/config/views.view.backlinks.yml b/config/views.view.backlinks.yml index 0e98426c8da7..4b06443f0627 100644 --- a/config/views.view.backlinks.yml +++ b/config/views.view.backlinks.yml @@ -1,5 +1,6 @@ disabled: true api_version: '3.0' +module: search name: backlinks description: 'Displays a list of nodes that link to the node, using the search backlinks table.' tag: default diff --git a/config/views.view.comments_recent.yml b/config/views.view.comments_recent.yml index 8450f7fc6efa..1c62bd486aec 100644 --- a/config/views.view.comments_recent.yml +++ b/config/views.view.comments_recent.yml @@ -1,5 +1,6 @@ disabled: true api_version: '3.0' +module: comment name: comments_recent description: 'Contains a block and a page to list recent comments; the block will automatically link to the page, which displays the comment body as well as a link to the node.' tag: default diff --git a/config/views.view.frontpage.yml b/config/views.view.frontpage.yml index 7b1af021cc6b..fb73c42c1ee7 100644 --- a/config/views.view.frontpage.yml +++ b/config/views.view.frontpage.yml @@ -1,5 +1,6 @@ disabled: true api_version: '3.0' +module: node name: frontpage description: 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.' tag: default diff --git a/config/views.view.glossary.yml b/config/views.view.glossary.yml index 9a8231c955f3..758a6bf08956 100644 --- a/config/views.view.glossary.yml +++ b/config/views.view.glossary.yml @@ -1,5 +1,6 @@ disabled: true api_version: '3.0' +module: node name: glossary description: 'A list of all content, by letter.' tag: default diff --git a/config/views.view.taxonomy_term.yml b/config/views.view.taxonomy_term.yml index 7fcf7c868aa8..66c3477ab340 100644 --- a/config/views.view.taxonomy_term.yml +++ b/config/views.view.taxonomy_term.yml @@ -1,5 +1,6 @@ disabled: true api_version: '3.0' +module: taxonomy name: taxonomy_term description: 'A view to emulate Drupal core''s handling of taxonomy/term.' tag: default diff --git a/config/views.view.tracker.yml b/config/views.view.tracker.yml index 1f4c9389c74a..41f6ce40284c 100644 --- a/config/views.view.tracker.yml +++ b/config/views.view.tracker.yml @@ -1,5 +1,6 @@ disabled: true api_version: '3.0' +module: node name: tracker description: 'Shows all new activity on system.' tag: default diff --git a/lib/Drupal/views/Tests/ViewStorageTest.php b/lib/Drupal/views/Tests/ViewStorageTest.php index 74832a15ceb6..6e300a7f859d 100644 --- a/lib/Drupal/views/Tests/ViewStorageTest.php +++ b/lib/Drupal/views/Tests/ViewStorageTest.php @@ -26,6 +26,7 @@ class ViewStorageTest extends WebTestBase { protected $config_properties = array( 'disabled', 'api_version', + 'module', 'name', 'description', 'tag', @@ -54,7 +55,7 @@ class ViewStorageTest extends WebTestBase { * * @var array */ - public static $modules = array('views'); + public static $modules = array('views', 'node', 'search', 'comment', 'taxonomy'); public static function getInfo() { return array( diff --git a/lib/Drupal/views/ViewStorage.php b/lib/Drupal/views/ViewStorage.php index 9700f007e616..0471d697a77e 100644 --- a/lib/Drupal/views/ViewStorage.php +++ b/lib/Drupal/views/ViewStorage.php @@ -118,6 +118,13 @@ class ViewStorage extends ConfigEntityBase implements ViewStorageInterface { */ public $original; + /** + * The module implementing this view. + * + * @var string + */ + public $module = 'views'; + /** * Stores the executable version of this view. * @@ -184,6 +191,13 @@ class ViewStorage extends ConfigEntityBase implements ViewStorageInterface { } } + /** + * Returns the name of the module implementing this view. + */ + public function getModule() { + return $this->module; + } + /** * Overrides Drupal\Core\Entity\EntityInterface::id(). */ diff --git a/lib/Drupal/views/ViewStorageController.php b/lib/Drupal/views/ViewStorageController.php index 25ca99fa2d82..744157c6ae11 100644 --- a/lib/Drupal/views/ViewStorageController.php +++ b/lib/Drupal/views/ViewStorageController.php @@ -23,6 +23,21 @@ class ViewStorageController extends ConfigStorageController { */ protected $uuidFactory = NULL; + /** + * Overrides Drupal\config\ConfigStorageController::load(); + */ + public function load(array $ids = NULL) { + $entities = parent::load($ids); + + // Only return views for enabled modules. + return array_filter($entities, function ($entity) { + if (module_exists($entity->getModule())) { + return TRUE; + } + return FALSE; + }); + } + /** * Overrides Drupal\config\ConfigStorageController::attachLoad(); */ @@ -80,6 +95,7 @@ class ViewStorageController extends ConfigStorageController { 'core', 'display', 'uuid', + 'module', ); foreach ($config_properties as $property) {