protected function ViewsEntitySchemaSubscriber::dataTableAddition in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::dataTableAddition()
Updates views if a data table is added.
Parameters
\Drupal\views\Entity\View[] $all_views: All views.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.
string $new_data_table: The new data table.
string $base_table: The base table.
1 call to ViewsEntitySchemaSubscriber::dataTableAddition()
- 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 315 - Contains \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber.
Class
- ViewsEntitySchemaSubscriber
- Reacts to changes on entity types to update all views entities.
Namespace
Drupal\views\EventSubscriberCode
protected function dataTableAddition($all_views, EntityTypeInterface $entity_type, $new_data_table, $base_table) {
/** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $storage */
$entity_type_id = $entity_type
->id();
$storage = $this->entityManager
->getStorage($entity_type_id);
$storage
->setEntityType($entity_type);
$table_mapping = $storage
->getTableMapping();
$data_table_fields = $table_mapping
->getFieldNames($new_data_table);
$base_table_fields = $table_mapping
->getFieldNames($base_table);
$data_table = $new_data_table;
$this
->processHandlers($all_views, function (array &$handler_config) use ($entity_type_id, $base_table, $data_table, $base_table_fields, $data_table_fields) {
if (isset($handler_config['entity_type']) && isset($handler_config['entity_field']) && $handler_config['entity_type'] == $entity_type_id) {
// Move all fields which just exists on the data table.
if ($handler_config['table'] == $base_table && in_array($handler_config['entity_field'], $data_table_fields) && !in_array($handler_config['entity_field'], $base_table_fields)) {
$handler_config['table'] = $data_table;
}
}
});
}