Use EntityTypeManagerInterface::getStorage()

Created on 15 June 2023, over 1 year ago

Problem/Motivation

Currently the overrides for entity storage replaces instances of \Drupal::entityTypeManager()->getStorage(''), but that does not work when using dependency injection to get the Entity Type Manager.

Steps to reproduce

use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\taxonomy\TermStorageInterface;

class Foo {

  protected TermStorageInterface $termStorage;

  public function __construct(
    EntityTypeManagerInterface $entityTypeManager,
  ) {
     // PhpStorm will complain that this is an EntityStorageInterface.
     $this->termStorage = $entityTypeManager->getStorage('taxonomy_term');
  }

}

Proposed resolution

Replace the override with the interface Drupal\Core\Entity\EntityTypeManagerInterface.

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡ͺSweden twod Sweden

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024