Problem/Motivation
Per the docs, the entityManager()
is being deprecated and will be replaced with the entityTypeManager()
instead.
in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager() instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service.
Drupal\Core\Controller\ControllerBase
class provides now deprecated entityManager()
method that is used in controllers across all core modules.
Proposed Solution
Replace calls to entityManager()
with entityTypeManager()
, or other appropriate service.
Remaining tasks
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Create a patch | Instructions | ||
Update the issue summary | Instructions | ||
Update the issue summary noting if allowed during the beta | Instructions | ||
Manually test the patch | Novice | Instructions | |
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions |
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#29 | 2691675_29-interdiff.txt | 10.8 KB | Berdir |
#29 | 2691675_29.patch | 53.58 KB | Berdir |
#23 | 2691675_23-interdiff.txt | 2.6 KB | Berdir |
#23 | 2691675_23.patch | 55.09 KB | Berdir |
#20 | 2691675_20-interdiff.txt | 940 bytes | Berdir |
Comments
Comment #2
dawehner#2624770: Use more specific entity.manager services in core.services.yml seems to do a lot of it already ...
Comment #4
20th CreditAttribution: 20th commented@dawehner
You are right, the patch in #2624770: Use more specific entity.manager services in core.services.yml already updates a lot of deprecated code, but it is focused specifically on services definitions and constructors and it is already enormous… And at the moment of this writing, needs a very big rebase.
On the contrary, this issue can focus specifically on usages of deprecated
entityManager()
method in controller classes, which is very common across all modules in core.Comment #5
dawehnerThank you for adding a good scope for this issue. Good point! Let's focus on this one thing here. This makes it easy to review and by that actually its doable to get in. Sorry for my previous comment.
Comment #6
20th CreditAttribution: 20th commentedComment #9
Mile23I think that's all of them...
I added a follow-up #2914956: Remove usages of EntityManager from EntityViewController because NodeController uses NodeViewController to render some output.
Comment #13
BerdirReroll, fixing the quickedit controller and also converting one more example from book.module.
I think it makes sense to deal with Node/EntityViewController in here too, it's easy to update and backwards compatible for sub-classes (once we add the new trait, which I'll do in the next update). Then we can add a @trigger_error() to ControllerBase::getEntityManager()
Comment #15
BerdirFixed that.
Comment #17
BerdirActually fixing the quickedit controller.
Comment #18
BerdirReroll, updating BC handling.
Comment #20
BerdirAdded missing constructor argument.
Comment #21
larowlanLooks good to me
Comment #22
Berdirthis is wrong. apparently this method is not actually called in core.
Comment #23
Berdirthis should fix that.
Comment #24
larowlanGood catch
Can you open an issue for removing it/finding out what title callback is used on that route?
Comment #25
BerdirThe title callback does point to that method, but that specific route sets a #title (through EntityViewBuilder); so going to that URL does not have to call the title callback. And nothing references that route in a way that requires us to resolve the title through the callback (e.g. breadcrumb), not in core anyway, so it's never called.
It possibly was called at some point, but then EntityViewController was refactored to set the #title through the render-trickery, so that quickedit works. Note that it actually can work on the preview page :)
So, not quite sure what to do about that..
Comment #26
BerdirCreated #3024386: Replace title callback on node preview route with a static title
Comment #27
alexpottI would turn these around to be
Because then in the future when we remove the deprecation we have less change to make and less code moves... i.e. we can remove the entire if and the
= NULL
from the constructor and we are done.There might be a compelling reason to do it the way round @Berdir has - if there is I'm +1 for re-rtbc :)
Comment #28
BerdirI don't have a reason, I think I copied that pattern in #2624770: Use more specific entity.manager services in core.services.yml from somewhere. Will have to update a lot of cases for that, but there are worse things ;)
Comment #29
BerdirUpdated that, also realized I missed one controller when adding the BC changes, changed that now to just use entityTypeManager() like it used entityManager() before.
Comment #30
alexpottThanks for the quick fixes. Marking rtbc as the changes are minimal. I've review all the service names in the deprecated code paths and they look good.
Comment #31
alexpottCommitted c23c05c and pushed to 8.7.x. Thanks!
Comment #32
alexpott