This entity reference selection handler already has entityManager injected, and uses it all over the place, so there's no reason for getReferenceableEntities() to use the deprecated procedural function for loading entities.

I figure this is safe for 8.0.x, but feel free to move it if you disagree.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz created an issue. See original summary.

bojanz’s picture

Priority: Normal » Minor
Status: Active » Needs review
FileSize
825 bytes

One-line fix.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

The entity manager is also already deprecated but it will continue to work if we just switch that out to the new service. Don't know if that's something that we can do in 8.x though as changing the injected services breaks subclasses with additional injections.

catch’s picture

Per https://www.drupal.org/node/2562903 class constructors are considered @internal so could change in minor releases.

This change I think we could make in 8.0.x though, so worth a follow-up for injecting the service directly.

Berdir’s picture

I've heard that before but I really think that is a bad idea and ignores the very valid case of overriding the constructor for additional dependencies.

It might not be so common for arbitrary services but for a class like this, which is basicaly a plugin base class that is meant to be overridden, with additional dependencies (entity storage is another example for this). In those cases, the statement from that link is a lie ( "These are objects where developers are not expected to call the constructor directly in the fist place").

See UserSelection in core for an example that would break if we change the constructor.

Anyway, not the right issue to discuss this ;)

catch’s picture

@Berdir, there might be cases we decide not to do it, and this case might be one of them.

  • catch committed f6ffab1 on 8.1.x
    Issue #2620658 by bojanz: Remove entity_load_multiple() usage from...

  • catch committed aa409bd on
    Issue #2620658 by bojanz: Remove entity_load_multiple() usage from...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.1.x and cherry-picked to 8.0.x, thanks!

However there are 13 other usages of this in core according to https://api.drupal.org/api/drupal/core!includes!entity.inc/function/enti... so would be great to have a follow-up to remove the other usages.

xjm’s picture

Issue tags: +Needs followup

Status: Fixed » Closed (fixed)

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