Allow override of processor plugins

Created on 12 August 2023, over 1 year ago
Updated 6 September 2023, over 1 year ago

Problem/Motivation

I had a need to modify the behavior of the dependent facet processor so that a particular facet would show only when another facet had exactly one specific value selected. I initially tried to do this by simply implementing my own processor plugin, with its own plugin ID. However, when the dependee facet conditional value was unselected, the filter from my custom dependent facet was still applied. It turns out that the facet plugin manager hard codes a reference to the "dependent_processor" plugin ID in the logic that decides whether a dependent processor should be applied, meaning that it was not applying the same logic to my custom dependent processor plugin as it had its own ID.

I took another approach to this by modifying the facet processor plugin manager to allow for plugin overrides.

Steps to reproduce

  • Define a custom dependent processor plugin with its own plugin ID that extends the dependent processor plugin that ships with the facets module.
  • Create a facet that is dependent (using this custome plugin) on another facet having a specific value.
  • In a search, try selecting that specific value for the dependee facet. Then apply a filter on the dependent facet that will now show because the dependee facet has that specific value selected.
  • Finally, unselect the specific value for the dependee facet

You will see that the filtering of the custom dependent facet is still applied on the underlying query.

Proposed resolution

I resolved this for myself by simply adding a line to the beginning of the constructor for the ProcessorPluginManager class that looks like:
$this->alterInfo('facet_processor_info');

This created a hook_facet_processor_info_alter() that I was then able to use for the purpose of creating a custom class that overrides the DependentFacetProcessor class while using the same plugin ID.

Remaining tasks

If the suggestion solution is acceptable, rolling a patch would be trivial.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ankur

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

Comments & Activities

Production build 0.71.5 2024