I have a list of files with filenames that sometimes only match the beginning of the title of entity they belong to so I thought it can be a nice addition to be able to choose the operator used for the search when using the entity_lookup process plugin.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rodrigoaguilera created an issue. See original summary.

rodrigoaguilera’s picture

Status: Active » Needs review
FileSize
1.2 KB

Here is a simple patch to demonstrate what I am referring to

Status: Needs review » Needs work

The last submitted patch, 2: 3121204-add-operator-2.patch, failed testing. View results

rodrigoaguilera’s picture

Status: Needs work » Needs review

It that a real failure?

rodrigoaguilera’s picture

Version: 8.x-5.x-dev » 8.x-4.x-dev
FileSize
1.2 KB

I include the patch for the 4.2 version for project that haven't updated yet

rodrigoaguilera’s picture

Version: 8.x-4.x-dev » 8.x-5.x-dev

well, it doesn't apply to 4,x, only to 4.2.

Back to 5.x where is relevant

rodrigoaguilera’s picture

Opened a MR to get some attention

heddn’s picture

Status: Needs review » Needs work
Matroskeen’s picture

Issue tags: +LutskGCW22, +Needs tests

Let's try to address feedback in the merge request and add a test coverage.

Matroskeen’s picture

Issue tags: -Needs tests

I put some test coverage for the new operator property, but it fails because of these lines:

// By default do a case-sensitive comparison.
    if (!$ignoreCase) {
      // Returns the entity's identifier.
      foreach ($results as $k => $identifier) {
        $entity = $this->entityTypeManager->getStorage($this->lookupEntityType)->load($identifier);
        $result_value = $entity instanceof ConfigEntityInterface ? $entity->get($this->lookupValueKey) : $entity->get($this->lookupValueKey)->value;
        if (($multiple && !in_array($result_value, $value, TRUE)) || (!$multiple && $result_value !== $value)) {
          unset($results[$k]);
        }
      }
    }

In the test example, $result_value is lucuma and $value is lucu.
That's why the result is removed.

Why do we have this? I haven't looked at the commit history yet. Perhaps the answer is there.

Matroskeen’s picture

Status: Needs work » Needs review

I published a few more commits - it's ready for review.

Matroskeen’s picture

Title: Add ability to choose the operator when performing an entity lookup » [backport] Add ability to choose the operator when performing an entity lookup
Status: Needs review » Patch (to be ported)

I self-reviewed it today and decided to go ahead and commit. If there are any suggestions/concerns, we can move them into a follow-up.

I'll also keep it open for backporting to 6.0 during the weekend so there is an opportunity to discuss if we can make it better.

Thanks!

Matroskeen’s picture

FileSize
0 bytes

I don't know what happened After #12, but all tests are failing now. Trying a patch to add missing return types.

Matroskeen’s picture

FileSize
1.07 KB

Ops, wrong file

Matroskeen’s picture

Status: Patch (to be ported) » Needs work

I reverted the last commit until we fix the test bot results.

Matroskeen’s picture

Status: Needs work » Needs review
FileSize
8.6 KB

Since I can't figure out why the test results are not showing up, but the tests are passing (we can see it in the job details), here is a new patch that contains MR changes + #16.

  • Matroskeen committed 1257c22 on 8.x-5.x
    Issue #3121204 by Matroskeen, rodrigoaguilera: Add ability to choose the...
Matroskeen’s picture

Version: 8.x-5.x-dev » 6.0.x-dev
FileSize
8.66 KB

Here is a patch for 6.0.x version

  • Matroskeen committed dae1881 on 6.0.x
    Issue #3121204 by Matroskeen, rodrigoaguilera: Add ability to choose the...
Matroskeen’s picture

Title: [backport] Add ability to choose the operator when performing an entity lookup » Add ability to choose the operator when performing an entity lookup
Status: Needs review » Fixed

Although the message is "Build Successful", the tests are passing according to the Test Report.

This is committed to 8.x-5.x and 6.0.x.
Thanks!

Status: Fixed » Closed (fixed)

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