Example #1
0
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $this->entityTypeId = $this->definition['entity_type'];
     $this->entityType = $this->entityManager->getDefinition($this->entityTypeId);
     $this->base_table = $this->entityType->getDataTable() ?: $this->entityType->getBaseTable();
     $this->base_field = $this->entityType->getKey('id');
 }
 /**
  * Processes the views data for a language field.
  *
  * @param string $table
  *   The table the language field is added to.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The field definition.
  * @param array $views_field
  *   The views field data.
  * @param string $field_column_name
  *   The field column being processed.
  */
 protected function processViewsDataForLanguage($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name)
 {
     // Apply special titles for the langcode field.
     if ($field_definition->getName() == 'langcode') {
         if ($table == $this->entityType->getDataTable() || $table == $this->entityType->getRevisionDataTable()) {
             $views_field['title'] = $this->t('Translation language');
         }
         if ($table == $this->entityType->getBaseTable() || $table == $this->entityType->getRevisionTable()) {
             $views_field['title'] = $this->t('Original language');
         }
     }
 }
 /**
  * Detects whether any table name got renamed in an entity type update.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The new entity type.
  * @param \Drupal\Core\Entity\EntityTypeInterface $original
  *   The origin entity type.
  *
  * @return bool
  *   Returns TRUE if there have been changes.
  */
 protected function hasSharedTableNameChanges(EntityTypeInterface $entity_type, EntityTypeInterface $original)
 {
     return $entity_type->getBaseTable() != $original->getBaseTable() || $entity_type->getDataTable() != $original->getDataTable() || $entity_type->getRevisionTable() != $original->getRevisionTable() || $entity_type->getRevisionDataTable() != $original->getRevisionDataTable();
 }
 /**
  * {@inheritdoc}
  */
 public function onEntityTypeDelete(EntityTypeInterface $entity_type)
 {
     $tables = [$entity_type->getBaseTable(), $entity_type->getDataTable(), $entity_type->getRevisionTable(), $entity_type->getRevisionDataTable()];
     $all_views = $this->entityManager->getStorage('view')->loadMultiple(NULL);
     /** @var \Drupal\views\Entity\View $view */
     foreach ($all_views as $id => $view) {
         // First check just the base table.
         if (in_array($view->get('base_table'), $tables)) {
             $view->disable();
             $view->save();
         }
     }
 }
Example #5
0
 /**
  * Gets the table of an entity type to be used as base table in views.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return string
  *   The name of the base table in views.
  */
 protected function getViewsTableForEntityType(EntityTypeInterface $entity_type)
 {
     return $entity_type->getDataTable() ?: $entity_type->getBaseTable();
 }