Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#10 | interdiff_5-10.txt | 1.51 KB | elber |
#10 | 3319446-10.patch | 1.99 KB | elber |
#5 | 3319446.patch | 542 bytes | Anchal_gupta |
Comments
Comment #2
adwivedi008 CreditAttribution: adwivedi008 at OpenSense Labs for DrupalFit commentedComment #3
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedComment #4
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedComment #5
Anchal_gupta CreditAttribution: Anchal_gupta at Material for Drupal India Association commentedI have uploaded the patch. Please review it
Comment #6
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedPlease use dependency injection.
Comment #7
elberComment #8
elberHi 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.
Comment #9
elberSorry I forgot to say we need to remove the entityFieldManager argument in the contruct because we doesn't need it anymore.
Comment #10
elberSorry I forgot to say we need to remove the entityFieldManager argument in the contruct because we doesn't need it anymore.
Comment #13
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedThanks Elber.
Fixed. Pushed to 2.0.x branch as well.