Problem/Motivation

phpstan was complaining about:

 ------ ---------------------------------------------------------------------- 
  Line   src/Plugin/Group/Relation/NotifyGroupNode.php                         
 ------ ---------------------------------------------------------------------- 
  289    \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 

That's for this line:

    return \Drupal::token()->replace($subject_config, $context);

For #3557728: Add GitLab CI pipelines and get all jobs passing I added this to the phpstan-baseline.neon for the project. However, it could be nice to fix this up to properly inject the token service, instead.

Steps to reproduce

Proposed resolution

Use DI to inject the token service for NotifyGroupNode
Remove this case from phpstan-baseline.neon

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dww created an issue. See original summary.

dww’s picture

Status: Active » Reviewed & tested by the community

In the absence of real automated tests, I did some manual local testing for this. It's working fine in 8.x-1.x branch. It's basically identical code for 2.0.x branch (the file just moved), so I have high confidence it works there, too. 😅 Pipelines are all green, so I know I didn't botch the phpstan baseline stuff.

  • dww committed af269de7 on 2.0.x
    task: #3557737 Inject 'token' service and stop using \Drupal::token() in...

  • dww committed c6cb6a0b on 8.x-1.x
    task: #3557737 Inject 'token' service and stop using \Drupal::token() in...
dww’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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