function ViewsEntitySchemaSubscriber::dataTableRename

Same name in other branches
  1. 9 core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::dataTableRename()
  2. 10 core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::dataTableRename()
  3. 11.x core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::dataTableRename()

Updates views if a data table is renamed.

Parameters

\Drupal\views\Entity\View[] $all_views: All views.

string $entity_type_id: The entity type ID.

string $old_data_table: The old data table name.

string $new_data_table: The new data table name.

1 call to ViewsEntitySchemaSubscriber::dataTableRename()
ViewsEntitySchemaSubscriber::onEntityTypeUpdate in core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php
Reacts to the update of the entity type.

File

core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php, line 338

Class

ViewsEntitySchemaSubscriber
Reacts to changes on entity types to update all views entities.

Namespace

Drupal\views\EventSubscriber

Code

protected function dataTableRename($all_views, $entity_type_id, $old_data_table, $new_data_table) {
    foreach ($all_views as $view) {
        if ($view->get('base_table') == $old_data_table) {
            $view->set('base_table', $new_data_table);
            $view->set('_updated', TRUE);
        }
    }
    $this->processHandlers($all_views, function (&$handler_config, ViewEntityInterface $view) use ($entity_type_id, $old_data_table, $new_data_table) {
        if (isset($handler_config['entity_type']) && $handler_config['entity_type'] == $entity_type_id && $handler_config['table'] == $old_data_table) {
            $handler_config['table'] = $new_data_table;
            $view->set('_updated', TRUE);
        }
    });
}

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