diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index 1dc6c8b..8193546 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -149,4 +149,20 @@ public function render($row) { return drupal_render_root($build); } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $view_mode = \Drupal::entityManager() + ->getStorage('entity_view') + ->load($this->options['view_mode']); + if ($view_mode) { + $dependencies['config'][] = $view_mode->getConfigDependencyName(); + } + + return $dependencies; + } + } diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php index 95dd59e..11ce27f 100644 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php @@ -939,8 +939,14 @@ function field_langcode(EntityInterface $entity) { * {@inheritdoc} */ public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + // Add the module providing the configured field storage as a dependency. - return array('config' => array($this->getFieldStorageConfig()->getConfigDependencyName())); + $dependencies['config'][] = $this->getFieldStorageConfig()->getConfigDependencyName(); + // Add the module providing the formatter. + if ($this->options['type']) { + $dependencies['module'][] = $this->formatterPluginManager->getDefinition($this->options['type'])['provider']; + } } /** diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index cf57b6f..7c859a1 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -374,4 +374,20 @@ public function getCacheContexts() { return $contexts; } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $role_storage = \Drupal::entityManager()->getStorage('taxonomy_vocabulary'); + foreach (array_keys($this->options['vid']) as $vocabulary_id) { + if ($vocabulary = $role_storage->load($vocabulary_id)) { + $dependencies['config'][] = $vocabulary->getConfigDependencyName(); + } + } + + return $dependencies; + } + } diff --git a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php index c0629c9..0236007 100644 --- a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php +++ b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php @@ -103,4 +103,20 @@ public function query() { $this->alias = $this->query->addRelationship($alias, $join, 'taxonomy_term_data', $this->relationship); } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $role_storage = \Drupal::entityManager()->getStorage('taxonomy_vocabulary'); + foreach (array_keys($this->options['vid']) as $vocabulary_id) { + if ($vocabulary = $role_storage->load($vocabulary_id)) { + $dependencies['config'][] = $vocabulary->getConfigDependencyName(); + } + } + + return $dependencies; + } + } diff --git a/core/modules/user/src/Plugin/views/access/Role.php b/core/modules/user/src/Plugin/views/access/Role.php index d821b11..a5bad55 100644 --- a/core/modules/user/src/Plugin/views/access/Role.php +++ b/core/modules/user/src/Plugin/views/access/Role.php @@ -92,4 +92,20 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { $form_state->setValue(array('access_options', 'role'), $role); } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $role_storage = \Drupal::entityManager()->getStorage('role'); + foreach (array_keys($this->options['role']) as $rid) { + if ($role = $role_storage->load($rid)) { + $dependencies['config'][] = $role->getConfigDependencyName(); + } + } + + return $dependencies; + } + } diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 167f169..0f0543c 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -254,8 +254,7 @@ public function calculateDependencies() { foreach ($executable->displayHandlers as $display) { // Add dependency for the display itself. - /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase $display */ - $this->addDependency('module', $display->getProvider()); + $this->calculatePluginDependencies($display); // Collect all dependencies of all handlers. foreach ($handler_types as $handler_type) { diff --git a/core/modules/views/src/Plugin/views/area/View.php b/core/modules/views/src/Plugin/views/area/View.php index 4e228bc..03f4ba5 100644 --- a/core/modules/views/src/Plugin/views/area/View.php +++ b/core/modules/views/src/Plugin/views/area/View.php @@ -151,4 +151,19 @@ public function isEmpty() { } } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + list($view_id, $display_id) = explode(':', $this->options['view_to_insert']); + if ($view_id) { + $view = \Drupal::entityManager()->getStorage('view')->load($view_id); + $dependencies['config'][] = $view->getConfigDependencyName(); + } + + return $dependencies; + } + } diff --git a/core/modules/views/src/Plugin/views/argument_validator/Entity.php b/core/modules/views/src/Plugin/views/argument_validator/Entity.php index ee2ab8c..b84a2ce 100644 --- a/core/modules/views/src/Plugin/views/argument_validator/Entity.php +++ b/core/modules/views/src/Plugin/views/argument_validator/Entity.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\argument_validator; +use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; @@ -211,4 +212,22 @@ protected function validateEntity(EntityInterface $entity) { return TRUE; } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $entity_type_id = $this->definition['entity_type']; + $bundle_entity_type = \Drupal::entityManager()->getDefinition($entity_type_id)->getBundleEntityType(); + $bundle_entity_storage = \Drupal::entityManager()->getStorage($bundle_entity_type); + + foreach (array_keys($this->options['bundles']) as $bundle) { + $bundle_entity = $bundle_entity_storage->load($bundle); + $key = $bundle_entity instanceof ConfigEntityInterface ? 'config' : 'content'; + $dependencies[$key][] = $bundle_entity->getConfigDependencyName(); + } + + return $dependencies; + } } diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index 3dd9a3d..b4fbd34 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -425,4 +425,19 @@ public function getPagerText() { ); } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $menu = $this->getOption('menu'); + if ($menu['type'] === 'normal') { + $menu_entity = \Drupal::entityManager()->getStorage('menu')->load($menu['menu_name']); + $dependencies['config'][] = $menu_entity->getConfigDependencyName(); + } + + return $dependencies; + } + } diff --git a/core/modules/views/src/Plugin/views/filter/Bundle.php b/core/modules/views/src/Plugin/views/filter/Bundle.php index 614a75c..a2a6514 100644 --- a/core/modules/views/src/Plugin/views/filter/Bundle.php +++ b/core/modules/views/src/Plugin/views/filter/Bundle.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\filter; +use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -73,4 +74,22 @@ public function query() { parent::query(); } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $bundle_entity_type = $this->entityType->getBundleEntityType(); + $bundle_entity_storage = \Drupal::entityManager()->getStorage($bundle_entity_type); + + foreach (array_keys($this->value) as $bundle) { + $bundle_entity = $bundle_entity_storage->load($bundle); + $key = $bundle_entity instanceof ConfigEntityInterface ? 'config' : 'content'; + $dependencies[$key][] = $bundle_entity->getConfigDependencyName(); + } + + return $dependencies; + } + } diff --git a/core/modules/views/src/Plugin/views/row/EntityRow.php b/core/modules/views/src/Plugin/views/row/EntityRow.php index 77f8a85..af27439 100644 --- a/core/modules/views/src/Plugin/views/row/EntityRow.php +++ b/core/modules/views/src/Plugin/views/row/EntityRow.php @@ -213,4 +213,20 @@ public function render($row) { return $this->getRenderer()->render($row); } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + $dependencies = parent::calculateDependencies(); + + $view_mode = \Drupal::entityManager() + ->getStorage('entity_view') + ->load($this->options['view_mode']); + if ($view_mode) { + $dependencies['config'][] = $view_mode->getConfigDependencyName(); + } + + return $dependencies; + } + }