As a half way house between deprecating entity procedural functions, maybe we could have some convenience methods on the entity manager as shortcuts for creating and loading entities?

So :

drupal_container()->get('plugin.manager.entity')->getStorageController('user')->create(array('value' => 'dfdfd'));

would become :

drupal_container()->get('plugin.manager.entity')->createEntity('user', array('value' => 'dfdfd'));

I'm not going to do any more on this for now, as the idea might just get shot down.

Comments

damiankloip’s picture

Issue summary: View changes

code block

dawehner’s picture

We probably want loadEntity and loadEntities.

damiankloip’s picture

StatusFileSize
new3.67 KB
new5.38 KB
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice, thought we should be clear that it's still encouraged to use the storage controller directly.

alexpott’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

Discussed this with @timplunkett and since #1893772: Move entity-type specific storage logic into entity classes and the improved typehints on storage controllers this would be a step back on properly injected code.

So... marking as "won't fix"... if @damiankloip or @dawehner feel this is wrong... re-open and explain... if we decide to kill all the entity_* wrappers then this will probably be a good compromise...

damiankloip’s picture

I would have at least postponed it on that basis, for review before release. I was under the impression that the entity_* wrappers were going, so IMO we need something like this instead.

andypost’s picture

andypost’s picture

Issue summary: View changes

Updated issue summary.