Problem/Motivation
\Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter doesn't declare the entityManager attribute in the class
Update:
As per suggestion by @alexpott in #4 replace deprecated entity.manager with entity_type.manager service.
Also fix the same for \Drupal\Core\Field\Plugin\Field\FieldFormatter\LanguageFormatter
Proposed resolution
Replace injection of deprecated service entity.manager
with entity_type.manager
in following classes:
\Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter
\Drupal\Core\Field\Plugin\Field\FieldFormatter\LanguageFormatter
Remaining tasks
Create a patch
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#11 | replace-depracated-entitymanager-2981025-11.patch | 5.79 KB | barthje |
#8 | interdiff6-8.txt | 1.73 KB | msankhala |
#8 | replace-depracated-entitymanager-2981025-8.patch | 5.78 KB | msankhala |
| |||
#6 | interdiff-2-6.txt | 5.78 KB | msankhala |
#6 | replace-depracated-entitymanager-2981025-6.patch | 5.72 KB | msankhala |
Comments
Comment #2
Stockticker CreditAttribution: Stockticker as a volunteer and at Drupal Ukraine Community commentedPlease review.
Comment #3
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commented@Stockticker Thanks for the patch. I can confirm this patch applies cleanly and declares the missing entityManager attribute of the class. Even though EntityManager is deprecated now I think that should be part of another issue.
Comment #4
alexpottNice find!
There's an additional problem here. The entity manager has been deprecated. So we're fixing something but then we'll have to change it in the future. Let's inject
entity_type.manager
into \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter instead and fix \Drupal\Core\Field\Plugin\Field\FieldFormatter\LanguageFormatter too. And then the new property can be called $entityTypeManager.Comment #5
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedComment #6
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commented@Stockticker Thanks for reporting this issue and initial patch. Here is updated patch.
Comment #7
alexpottNeeds a description as per coding standards
Comment #8
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedAhh.. silly mistake. :) Added param description.
Comment #9
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedComment #10
barthje CreditAttribution: barthje commentedI noticed you corrected the comments in one place to "the entity type manager" but in StringFormatter you call it "The entity manager" again, it should be the entity type manager.
Comment #11
barthje CreditAttribution: barthje commentedComment #12
Mirnaxvb CreditAttribution: Mirnaxvb as a volunteer and at Synetic commentedAll comments are correct now.
Comment #13
catchCommitted 62e59a0 and pushed to 8.6.x. Thanks!
Comment #15
catchComment #16
penyaskitoNot sure how we should deal with this. But even if it wasn't declared, people may assume there is a property (dynamic) called
$entityManager
. This would be a backward compatibility issue then if we "rename" it to$entityTypeManager
.