You are here

protected function ViewsConfigUpdater::processDisplayHandlers in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/ViewsConfigUpdater.php \Drupal\views\ViewsConfigUpdater::processDisplayHandlers()
  2. 9 core/modules/views/src/ViewsConfigUpdater.php \Drupal\views\ViewsConfigUpdater::processDisplayHandlers()

Processes all display handlers.

Parameters

\Drupal\views\ViewEntityInterface $view: The View to update.

bool $return_on_changed: Whether processing should stop after a change is detected.

callable $handler_processor: A callback performing the actual update.

Return value

bool Whether the view was updated.

File

core/modules/views/src/ViewsConfigUpdater.php, line 126

Class

ViewsConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\views

Code

protected function processDisplayHandlers(ViewEntityInterface $view, $return_on_changed, callable $handler_processor) {
  $changed = FALSE;
  $displays = $view
    ->get('display');
  $handler_types = [
    'field',
    'argument',
    'sort',
    'relationship',
    'filter',
  ];
  foreach ($displays as $display_id => &$display) {
    foreach ($handler_types as $handler_type) {
      $handler_type_plural = $handler_type . 's';
      if (!empty($display['display_options'][$handler_type_plural])) {
        foreach ($display['display_options'][$handler_type_plural] as $key => &$handler) {
          if ($handler_processor($handler, $handler_type, $key, $display_id)) {
            $changed = TRUE;
            if ($return_on_changed) {
              return $changed;
            }
          }
        }
      }
    }
  }
  if ($changed) {
    $view
      ->set('display', $displays);
  }
  return $changed;
}