The EntityTypeManager is injected, but should be typehinted as EntityTypeManagerInterface.
Modules like Webprofiler also implement this interface.

This:

  /**
   * Constructs a CookieCategoryForm object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManager $entityTypeManager
   *   The entityTypeManager.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public function __construct(EntityTypeManager $entityTypeManager) {
    $this->entityTypeManager = $entityTypeManager;
    $this->categoryStorageManager = $entityTypeManager->getStorage('cookie_category');
  }

Should become:

  /**
   * Constructs a CookieCategoryForm object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entityTypeManager.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
    $this->entityTypeManager = $entityTypeManager;
    $this->categoryStorageManager = $entityTypeManager->getStorage('cookie_category');
  }

I have attached a patch below.
Please advise.

Comments

Tom_VDB created an issue. See original summary.

svenryen’s picture

Status: Active » Needs review

  • svenryen committed b14f798 on 8.x-1.x authored by Tom_VDB
    Issue #3193731 by Tom_VDB, svenryen: CookieCategoryForm: DI...
svenryen’s picture

Status: Needs review » Fixed

Fixed - thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.