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.
Follow up for #1982980: Move entity_get_form to Drupal\Core\Entity\EntityManager::getForm() and various others
Problem/Motivation
We have lots of Drupal::service('plugin.manager.entity')-> throughout core, adding Drupal::EntityManager would improve DX
Proposed resolution
Add new method to return the entity manager service to Drupal static
Remaining tasks
Write the patch
Convert existing calls
Review
User interface changes
None
API changes
New method on Drupal
Comment | File | Size | Author |
---|---|---|---|
#3 | entity-manager-service-1982984.1.patch | 28.41 KB | larowlan |
Comments
Comment #1
tim.plunkett+1
Comment #2
msonnabaum CreditAttribution: msonnabaum commented+1 in general, although I'd rather have a static method per entity type.
Comment #3
larowlanFirst crack
On a related note.
It seems bizarre to me that Entity needed to call drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->save($this);
Why not $this->storage->save($this);
but obviously something else going on there?
Comment #4
tim.plunkettAll of the \Drupals and Drupals look in order, if this is green, it's RTBC.
Comment #5
andypostAwesome clean-up, +1 to commit
Comment #6
webchickYay for killing more drupal_container() calls!
I thought it was kinda weird that entity-related stuff is in Drupal:: and not Entity::
Tim Plunkett explained that the core entity service is provided by core.services.yml, so it rightly belongs in Drupal:: for now. Entity module is more like an "Entity UI" module at this point, rather than an API module, so doesn't make as much sense to lump it under there.
This seems like something we'll want to clean up eventually (Tim mentioned #1043198: Convert view modes to ConfigEntity as one place where this is in partial progress), but for now I think it's ok.
Committed and pushed to 8.x. Thanks!