function ViewsConfigUpdater::processTaxonomyTermFilterHandler

Processes taxonomy_index_tid type filters.

Parameters

array $handler: A display handler.

string $handler_type: The handler type.

\Drupal\views\ViewEntityInterface $view: The View being updated.

Return value

bool Whether the handler was updated.

1 call to ViewsConfigUpdater::processTaxonomyTermFilterHandler()
ViewsConfigUpdater::needsTaxonomyTermFilterUpdate in core/modules/views/src/ViewsConfigUpdater.php
Removes user context from all views using term filter configurations.

File

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

Class

ViewsConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\views

Code

protected function processTaxonomyTermFilterHandler(array &$handler, string $handler_type, ViewEntityInterface $view) : bool {
    $changed = FALSE;
    // Force view resave if using taxonomy id filter.
    $plugin_id = $handler['plugin_id'] ?? '';
    if ($handler_type === 'filter' && $plugin_id === 'taxonomy_index_tid') {
        // This cannot be done in View::preSave() due to trusted data.
        $executable = $view->getExecutable();
        $displays = $view->get('display');
        foreach ($displays as $display_id => &$display) {
            $executable->setDisplay($display_id);
            $cache_metadata = $executable->getDisplay()
                ->calculateCacheMetadata();
            $display['cache_metadata']['contexts'] = $cache_metadata->getCacheContexts();
            // Always include at least the 'languages:' context as there will most
            // probably be translatable strings in the view output.
            $display['cache_metadata']['contexts'] = Cache::mergeContexts($display['cache_metadata']['contexts'], [
                'languages:' . LanguageInterface::TYPE_INTERFACE,
            ]);
            sort($display['cache_metadata']['contexts']);
        }
        $view->set('display', $displays);
        $changed = TRUE;
    }
    return $changed;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.