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

CommentFileSizeAuthor
#3 entity-manager-service-1982984.1.patch28.41 KBlarowlan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Title: Create Drupal::EntityManager for improved DX » Create Drupal::entityManager for improved DX

+1

msonnabaum’s picture

+1 in general, although I'd rather have a static method per entity type.

larowlan’s picture

Assigned: larowlan » Unassigned
Status: Active » Needs review
FileSize
28.41 KB

First 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?

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Quick fix

All of the \Drupals and Drupals look in order, if this is green, it's RTBC.

andypost’s picture

Awesome clean-up, +1 to commit

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Yay 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!

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