diff --git a/core/modules/comment/src/CommentBreadcrumbBuilder.php b/core/modules/comment/src/CommentBreadcrumbBuilder.php index eb8104c1e2a14af5162cdff9c82a67166ad49f65..72291afbf10f97a7e40174364326ba011a716b4e 100644 --- a/core/modules/comment/src/CommentBreadcrumbBuilder.php +++ b/core/modules/comment/src/CommentBreadcrumbBuilder.php @@ -16,11 +16,11 @@ class CommentBreadcrumbBuilder implements BreadcrumbBuilderInterface { use StringTranslationTrait; /** - * The comment storage. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityStorageInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $storage; + protected $entityTypeManager; /** * Constructs the CommentBreadcrumbBuilder. @@ -29,7 +29,7 @@ class CommentBreadcrumbBuilder implements BreadcrumbBuilderInterface { * The entity type manager. */ public function __construct(EntityTypeManagerInterface $entity_type_manager) { - $this->storage = $entity_type_manager->getStorage('comment'); + $this->entityTypeManager = $entity_type_manager; } /** @@ -51,7 +51,7 @@ public function build(RouteMatchInterface $route_match) { $breadcrumb->addLink(new Link($entity->label(), $entity->toUrl())); $breadcrumb->addCacheableDependency($entity); - if (($pid = $route_match->getParameter('pid')) && ($comment = $this->storage->load($pid))) { + if (($pid = $route_match->getParameter('pid')) && ($comment = $this->entityTypeManager->getStorage('comment')->load($pid))) { /** @var \Drupal\comment\CommentInterface $comment */ $breadcrumb->addCacheableDependency($comment); // Display link to parent comment. diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php index 921b77a36eae485c4f64c9645df21725343ff181..15c894be7a6c553951e82201898d5c8acd87133f 100644 --- a/core/modules/node/src/Plugin/views/row/Rss.php +++ b/core/modules/node/src/Plugin/views/row/Rss.php @@ -2,8 +2,6 @@ namespace Drupal\node\Plugin\views\row; -use Drupal\Core\Entity\EntityDisplayRepositoryInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\views\Plugin\views\row\RssPluginBase; /** @@ -35,32 +33,6 @@ class Rss extends RssPluginBase { */ protected $entityTypeId = 'node'; - /** - * The node storage. - * - * @var \Drupal\node\NodeStorageInterface - */ - protected $nodeStorage; - - /** - * Constructs the Rss object. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository - * The entity display repository. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository = NULL) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_display_repository); - $this->nodeStorage = $entity_type_manager->getStorage('node'); - } - /** * {@inheritdoc} */ @@ -82,7 +54,7 @@ public function preRender($values) { $nids[] = $row->{$this->field_alias}; } if (!empty($nids)) { - $this->nodes = $this->nodeStorage->loadMultiple($nids); + $this->nodes = $this->entityTypeManager->getStorage('node')->loadMultiple($nids); } } diff --git a/core/modules/taxonomy/src/TermBreadcrumbBuilder.php b/core/modules/taxonomy/src/TermBreadcrumbBuilder.php index 7ae4bd5e32283eee4f75816487c47d669685a735..89252df4bee8c908ee0bd8c33f2b1cde3a735dd1 100644 --- a/core/modules/taxonomy/src/TermBreadcrumbBuilder.php +++ b/core/modules/taxonomy/src/TermBreadcrumbBuilder.php @@ -30,13 +30,6 @@ class TermBreadcrumbBuilder implements BreadcrumbBuilderInterface { */ protected $entityTypeManager; - /** - * The taxonomy storage. - * - * @var \Drupal\taxonomy\TermStorageInterface - */ - protected $termStorage; - /** * Constructs the TermBreadcrumbBuilder. * @@ -47,7 +40,6 @@ class TermBreadcrumbBuilder implements BreadcrumbBuilderInterface { */ public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository) { $this->entityTypeManager = $entity_type_manager; - $this->termStorage = $entity_type_manager->getStorage('taxonomy_term'); $this->entityRepository = $entity_repository; } @@ -73,7 +65,7 @@ public function build(RouteMatchInterface $route_match) { // @todo This overrides any other possible breadcrumb and is a pure // hard-coded presumption. Make this behavior configurable per // vocabulary or term. - $parents = $this->termStorage->loadAllParents($term->id()); + $parents = $this->entityTypeManager->getStorage('taxonomy_term')->loadAllParents($term->id()); // Remove current term being accessed. array_shift($parents); foreach (array_reverse($parents) as $term) { diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index 39d7da5e14c80d46e1b69336028ee36fbccdf9a8..0f3679d5fc7de458fefd45d132200dac23a260a3 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -95,7 +95,6 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable $token_service = \Drupal::token(); $replacements = []; - $taxonomy_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); if ($type == 'term' && !empty($data['term'])) { $term = $data['term']; @@ -134,6 +133,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable break; case 'parent': + $taxonomy_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); if ($parents = $taxonomy_storage->loadParents($term->id())) { $parent = array_pop($parents); $bubbleable_metadata->addCacheableDependency($parent); @@ -148,9 +148,12 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable $replacements += $token_service->generate('vocabulary', $vocabulary_tokens, ['vocabulary' => $vocabulary], $options, $bubbleable_metadata); } - if (($vocabulary_tokens = $token_service->findWithPrefix($tokens, 'parent')) && $parents = $taxonomy_storage->loadParents($term->id())) { - $parent = array_pop($parents); - $replacements += $token_service->generate('term', $vocabulary_tokens, ['term' => $parent], $options, $bubbleable_metadata); + if (($vocabulary_tokens = $token_service->findWithPrefix($tokens, 'parent'))) { + $taxonomy_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); + if ($parents = $taxonomy_storage->loadParents($term->id())) { + $parent = array_pop($parents); + $replacements += $token_service->generate('term', $vocabulary_tokens, ['term' => $parent], $options, $bubbleable_metadata); + } } } @@ -182,6 +185,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable break; case 'node-count': + $taxonomy_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); $replacements[$original] = $taxonomy_storage->nodeCount($vocabulary->id()); break; }