Problem/Motivation

Dependency injection is not working and showing Using $this when not in object context error

Steps to reproduce

1. Install on D10
2. Try to replace any term with another one

Proposed resolution

On line no 84 of CleanTaxonomyReplaceForm instead of using D.I. we can call Service

 $entityFieldManager = $this->entityFieldManager;
To  \Drupal::service('entity_field.manager');

Remaining tasks

Instead of using Service DI should be preferred

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#10 interdiff_5-10.txt1.51 KBelber
#10 3319446-10.patch1.99 KBelber
#5 3319446.patch542 bytesAnchal_gupta
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adwivedi008 created an issue. See original summary.

adwivedi008’s picture

Title: n the controller and form files, We should use dependency injection. » In the controller and form files, We should use dependency injection.
anmolgoyal74’s picture

Status: Needs work » Active
anmolgoyal74’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Anchal_gupta’s picture

Status: Active » Needs review
FileSize
542 bytes

I have uploaded the patch. Please review it

anmolgoyal74’s picture

Status: Needs review » Needs work

Please use dependency injection.

elber’s picture

Assigned: Unassigned » elber
elber’s picture

Assigned: elber » Unassigned
Status: Needs work » Reviewed & tested by the community

Hi moving to RTBC because we can't do dependency injection in static functions or methods because it doesn't belong to the object.

I revised and applied the patch and the keeps working as expected.

elber’s picture

Assigned: Unassigned » elber
Status: Reviewed & tested by the community » Needs work

Sorry I forgot to say we need to remove the entityFieldManager argument in the contruct because we doesn't need it anymore.

elber’s picture

Assigned: elber » Unassigned
Status: Needs work » Needs review
FileSize
1.99 KB
1.51 KB

Sorry I forgot to say we need to remove the entityFieldManager argument in the contruct because we doesn't need it anymore.

  • anmolgoyal74 committed b797fac on 8.x-1.x
    Issue #3319446 by elber, Anchal_gupta: In the controller and form files...

  • anmolgoyal74 committed 5492b38 on 2.0.x
    Issue #3319446 by elber, Anchal_gupta: In the controller and form files...
anmolgoyal74’s picture

Status: Needs review » Fixed

Thanks Elber.
Fixed. Pushed to 2.0.x branch as well.

Status: Fixed » Closed (fixed)

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