Entity Finder: add return field option

Created on 27 February 2025, 3 months ago

Followup from 📌 D7 EFQ Finder to D8 Entity finder Needs work

Problem/Motivation

The Entity Finder plugin allows you to lookup an existing content entity by searching for a specific value on a field. As of now, the plugin can only return the ID of the entity that was found.

It would be useful if the plugin would also be able to return the value of a field on the entity.

Proposed resolution

Before the Entity Finder plugin was finished, @hepabolu made a similar plugin that includes an option called "return_field".
https://github.com/hepabolu/feeds_tamper_lookup_entity

The idea is to port that option to the Tamper plugin "Entity Finder" and add test coverage for it.

The default option for the return field should be the entity ID field.

Remaining tasks

  • Add a new configuration key called "return_field" (declare it in tamper.schema.yml for "tamper.entity_finder").
  • On the configuration form, add a field to configure the return field. Make it appear after an entity type is chosen and limit it to bundle, if applicable.
  • In the tamper() method, make sure that the field value is returned if a return field is configured.
  • Add a test coverage:
    • Add a test case to \Drupal\Tests\tamper\Functional\Plugin\Tamper\EntityFinderTest, covering that the field appears after selecting an entity type.
    • Add a test case to \Drupal\Tests\tamper\Functional\Plugin\Tamper\EntityFinderTest, covering that the field's options are limited to fields in a bundle after a bundle is chosen.
    • Add a test case to \Drupal\Tests\tamper\FunctionalJavascript\Plugin\Tamper\EntityFinderTest, covering that the field appears after selecting an entity type.
    • Add a test case to \Drupal\Tests\tamper\FunctionalJavascript\Plugin\Tamper\EntityFinderTest, covering that the field's options are limited to fields in a bundle after a bundle is chosen.
    • Add a test case to \Drupal\Tests\tamper\Kernel\Plugin\Tamper\EntityFinderTest, covering that a field value is returned when a return field is configured.

User interface changes

When configuring an instance of the Entity Finder plugin, a new option called "Return field" appears.

API changes

None.

Data model changes

A new config key called "return_field" is added to the entity finder plugin.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇳🇱Netherlands megachriz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024