Remove service location anti-patterns in constructors: forum

Created on 27 May 2023, almost 2 years ago
Updated 24 April 2024, 12 months ago

@mglaman pointed out the possible problem of these three patterns in the class constructor in his blog:
$this->request = $request_stack->getCurrentRequest();
$this->nodeStorage = $entity_type_manager->getStorage('node');
$this->config = $config_factory->get('mymodule.settings');

The following classes are affected:
Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase

$entity_type_manager->getStorage():
Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase

📌 Task
Status

Active

Version

1.0

Component

forum.module

Created by

🇩🇪Germany sleitner

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

Comments & Activities

Production build 0.71.5 2024