Remove service location anti-patterns in constructors: comments

Created on 27 May 2023, about 1 year ago
Updated 1 June 2023, about 1 year 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:
$config_factory->get():
Drupal\comment\CommentManager

$entity_type_manager->getStorage():
Drupal\comment\Form\CommentAdminOverview
Drupal\comment\Plugin\Field\FieldFormatter\CommentDefaultFormatter

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
CommentΒ  β†’

Last updated 2 days ago

Created by

πŸ‡©πŸ‡ͺGermany sleitner

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024