Drupal 9 image field migration

The issue related to the custom website with custom field for phone. It has spaces. One of the solution is to remove spaces on presave and process the old entries in DB removing the spaces.
But sometimes it better not to touch thing that works.
The task was to provide search by phone filter in views. There are no default methods in views to search with removed spaces. In this case I've found a solution to alter the query.
So for example the phone fields value is "+354 566 32 56" and we need to find it by searching "6632" string.
This code will help you with it:

/**
 * Implements hook_views_query_alter().
 *
 * @param ViewExecutable $view
 * @param Sql $query
 */
function custommodule_views_query_alter(ViewExecutable $view, Sql $query) {
  if ($view->id() == 'commerce_orders' && $view->current_display == 'orders') {
    // Traverse through the 'where' part of the query.
    foreach ($query->where as &$condition_group) {
      foreach ($condition_group['conditions'] as &$condition) {
        // Replace whitespaces from phone field.
        if ($condition['operator'] == 'formula' && !empty(strpos($condition['field'], 'field_phone_number'))) {
          $condition['field'] = preg_replace(['/CONCAT_WS/','/[)]/'], ['REPLACE(CONCAT_WS', "), ' ', '')"], $condition['field'] );
        }
      }
    }
  }
}

Коментувати

Вміст цього поля є приватним і не буде доступний широкому загалу.
  • Не дозволено жодних HTML теґів.
 d88    888888ba   dP     dP   a88888b.  dP     dP 
88 88 `8b 88 88 d8' `88 88 .d8'
88 a88aaaa8P' 88 .8P 88 88aaa8P'
88 88 `8b. 88 d8' 88 88 `8b.
88 88 88 88 .d8P Y8. .88 88 88
d88P dP dP 888888' Y88888P' dP dP

Уведіть код, зображений у стилі Ascii-Арт.