The docs for \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter references that an entity manager should be provided, but it is incorrect. Instead \Drupal::entityManager() is used in the code instead of it being injected. We also use the deprecated entity_view() function.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid created an issue. See original summary.

Dave Reid’s picture

Status: Active » Needs review
FileSize
4.35 KB
Dave Reid’s picture

amateescu’s picture

Component: field system » entity_reference.module
Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
    @@ -95,7 +105,7 @@ public static function defaultSettings() {
    +      '#options' => $this->entityManager->getViewModeOptions($this->getFieldSetting('target_type')),
    

    We should use the 'entity_display.repository' service now.

  2. +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
    @@ -134,7 +144,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
    +        $view_builder = $this->entityManager->getViewBuilder($entity->getEntityTypeId());
    

    And the 'entity_type.manager' service here.

amateescu’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
4.6 KB

Fixed the two minor review points from above.. the patch didn't apply anymore so there's no interdiff.

The changes are very small so I'm setting this straight to RTBC.

catch’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Reviewed & tested by the community » Fixed

Due to the constructor changes this needs to go into a minor release only. Committed/pushed to 8.1.x, thanks!

  • catch committed 6cbd448 on
    Issue #2562099 by Dave Reid, amateescu: EntityReferenceEntityFormatter...

Status: Fixed » Closed (fixed)

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