Reorganize controller to make it easier to extend

Created on 8 October 2024, about 1 month ago

Problem/Motivation

For now, AutocompleteController::handleAutocomplete method handles three tasks:

  1. Getting field and field widget settings
  2. Get existing field values from database
  3. Format field values to return

Sometimes you might need to change the logic a little bit. Then you have two options:

  1. Extend the AutocompleteController and overwrite whole handleAutocomplete method
  2. Create a patch

Proposed resolution

I think, the three tasks mentioned above can be split to multiple methods. At least, the second task should have the separate method.

For now, the field values are gained from database by a query in handleAutocomplete method. But there are also other ways to gain data. There is an issue regarding gaining values by Views - Use Views for search β†’ . Some developer might need to add another way or adjust one of these two existing ways.

I think, there could be a new method, that would contain mentioned switch (which way to use) and existing database query could have its own method, too. The it would be easier for developer to extend the class to adjust the logic for some custom needs.

I am willing to work on the task, but I think, the issue about coding standards β†’ should be solved first.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia tomas.teicher

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

Comments & Activities

Production build 0.71.5 2024