diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index 8193546..cc9c946 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -8,6 +8,7 @@ namespace Drupal\comment\Plugin\views\row; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Plugin\views\EntityViewModeDependencyTrait; use Drupal\views\Plugin\views\row\RowPluginBase; /** @@ -25,6 +26,8 @@ */ class Rss extends RowPluginBase { + use EntityViewModeDependencyTrait; + var $base_table = 'comment'; var $base_field = 'cid'; @@ -149,20 +152,4 @@ 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/views/src/Plugin/views/EntityViewModeDependencyTrait.php b/core/modules/views/src/Plugin/views/EntityViewModeDependencyTrait.php new file mode 100644 index 0000000..0780ba2 --- /dev/null +++ b/core/modules/views/src/Plugin/views/EntityViewModeDependencyTrait.php @@ -0,0 +1,31 @@ +getStorage('entity_view_mode') + ->load($this->options['view_mode']); + if ($view_mode) { + $dependencies['config'][] = $view_mode->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 af27439..20ad322 100644 --- a/core/modules/views/src/Plugin/views/row/EntityRow.php +++ b/core/modules/views/src/Plugin/views/row/EntityRow.php @@ -13,6 +13,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; +use Drupal\views\Plugin\views\EntityViewModeDependencyTrait; use Drupal\views\ViewExecutable; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -26,6 +27,8 @@ */ class EntityRow extends RowPluginBase { + use EntityViewModeDependencyTrait; + /** * The table the entity is using for storage. * @@ -213,20 +216,4 @@ 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; - } - }