Chris@0: entityType = $entity_type; Chris@0: $this->entityManager = $entity_manager; Chris@0: $this->storage = $storage_controller; Chris@0: $this->moduleHandler = $module_handler; Chris@0: $this->setStringTranslation($translation_manager); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { Chris@0: return new static( Chris@0: $entity_type, Chris@0: $container->get('entity.manager')->getStorage($entity_type->id()), Chris@0: $container->get('entity.manager'), Chris@0: $container->get('module_handler'), Chris@0: $container->get('string_translation'), Chris@0: $container->get('typed_data_manager') Chris@0: ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the field storage definitions. Chris@0: * Chris@0: * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[] Chris@0: */ Chris@0: protected function getFieldStorageDefinitions() { Chris@0: if (!isset($this->fieldStorageDefinitions)) { Chris@0: $this->fieldStorageDefinitions = $this->entityManager->getFieldStorageDefinitions($this->entityType->id()); Chris@0: } Chris@0: return $this->fieldStorageDefinitions; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getViewsData() { Chris@0: $data = []; Chris@0: Chris@0: $base_table = $this->entityType->getBaseTable() ?: $this->entityType->id(); Chris@0: $views_revision_base_table = NULL; Chris@0: $revisionable = $this->entityType->isRevisionable(); Chris@0: $base_field = $this->entityType->getKey('id'); Chris@0: Chris@0: $revision_table = ''; Chris@0: if ($revisionable) { Chris@0: $revision_table = $this->entityType->getRevisionTable() ?: $this->entityType->id() . '_revision'; Chris@0: } Chris@0: Chris@0: $translatable = $this->entityType->isTranslatable(); Chris@0: $data_table = ''; Chris@0: if ($translatable) { Chris@0: $data_table = $this->entityType->getDataTable() ?: $this->entityType->id() . '_field_data'; Chris@0: } Chris@0: Chris@0: // Some entity types do not have a revision data table defined, but still Chris@0: // have a revision table name set in Chris@0: // \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout() so we Chris@0: // apply the same kind of logic. Chris@0: $revision_data_table = ''; Chris@0: if ($revisionable && $translatable) { Chris@0: $revision_data_table = $this->entityType->getRevisionDataTable() ?: $this->entityType->id() . '_field_revision'; Chris@0: } Chris@0: $revision_field = $this->entityType->getKey('revision'); Chris@0: Chris@0: // Setup base information of the views data. Chris@0: $data[$base_table]['table']['group'] = $this->entityType->getLabel(); Chris@0: $data[$base_table]['table']['provider'] = $this->entityType->getProvider(); Chris@0: Chris@0: $views_base_table = $base_table; Chris@0: if ($data_table) { Chris@0: $views_base_table = $data_table; Chris@0: } Chris@0: $data[$views_base_table]['table']['base'] = [ Chris@0: 'field' => $base_field, Chris@0: 'title' => $this->entityType->getLabel(), Chris@0: 'cache_contexts' => $this->entityType->getListCacheContexts(), Chris@0: ]; Chris@0: $data[$base_table]['table']['entity revision'] = FALSE; Chris@0: Chris@0: if ($label_key = $this->entityType->getKey('label')) { Chris@0: if ($data_table) { Chris@0: $data[$views_base_table]['table']['base']['defaults'] = [ Chris@0: 'field' => $label_key, Chris@0: 'table' => $data_table, Chris@0: ]; Chris@0: } Chris@0: else { Chris@0: $data[$views_base_table]['table']['base']['defaults'] = [ Chris@0: 'field' => $label_key, Chris@0: ]; Chris@0: } Chris@0: } Chris@0: Chris@0: // Entity types must implement a list_builder in order to use Views' Chris@0: // entity operations field. Chris@0: if ($this->entityType->hasListBuilderClass()) { Chris@0: $data[$base_table]['operations'] = [ Chris@0: 'field' => [ Chris@0: 'title' => $this->t('Operations links'), Chris@0: 'help' => $this->t('Provides links to perform entity operations.'), Chris@0: 'id' => 'entity_operations', Chris@0: ], Chris@0: ]; Chris@14: $data[$revision_table]['operations'] = [ Chris@14: 'field' => [ Chris@14: 'title' => $this->t('Operations links'), Chris@14: 'help' => $this->t('Provides links to perform entity operations.'), Chris@14: 'id' => 'entity_operations', Chris@14: ], Chris@14: ]; Chris@0: } Chris@0: Chris@0: if ($this->entityType->hasViewBuilderClass()) { Chris@0: $data[$base_table]['rendered_entity'] = [ Chris@0: 'field' => [ Chris@0: 'title' => $this->t('Rendered entity'), Chris@0: 'help' => $this->t('Renders an entity in a view mode.'), Chris@0: 'id' => 'rendered_entity', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: Chris@0: // Setup relations to the revisions/property data. Chris@0: if ($data_table) { Chris@0: $data[$base_table]['table']['join'][$data_table] = [ Chris@0: 'left_field' => $base_field, Chris@0: 'field' => $base_field, Chris@17: 'type' => 'INNER', Chris@0: ]; Chris@0: $data[$data_table]['table']['group'] = $this->entityType->getLabel(); Chris@0: $data[$data_table]['table']['provider'] = $this->entityType->getProvider(); Chris@0: $data[$data_table]['table']['entity revision'] = FALSE; Chris@0: } Chris@0: if ($revision_table) { Chris@0: $data[$revision_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]); Chris@0: $data[$revision_table]['table']['provider'] = $this->entityType->getProvider(); Chris@0: Chris@0: $views_revision_base_table = $revision_table; Chris@0: if ($revision_data_table) { Chris@0: $views_revision_base_table = $revision_data_table; Chris@0: } Chris@0: $data[$views_revision_base_table]['table']['entity revision'] = TRUE; Chris@0: $data[$views_revision_base_table]['table']['base'] = [ Chris@0: 'field' => $revision_field, Chris@0: 'title' => $this->t('@entity_type revisions', ['@entity_type' => $this->entityType->getLabel()]), Chris@0: ]; Chris@0: // Join the revision table to the base table. Chris@0: $data[$views_revision_base_table]['table']['join'][$views_base_table] = [ Chris@0: 'left_field' => $revision_field, Chris@0: 'field' => $revision_field, Chris@0: 'type' => 'INNER', Chris@0: ]; Chris@0: Chris@0: if ($revision_data_table) { Chris@0: $data[$revision_data_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]); Chris@0: $data[$revision_data_table]['table']['entity revision'] = TRUE; Chris@0: Chris@0: $data[$revision_table]['table']['join'][$revision_data_table] = [ Chris@0: 'left_field' => $revision_field, Chris@0: 'field' => $revision_field, Chris@0: 'type' => 'INNER', Chris@0: ]; Chris@0: } Chris@0: Chris@0: // Add a filter for showing only the latest revisions of an entity. Chris@0: $data[$revision_table]['latest_revision'] = [ Chris@0: 'title' => $this->t('Is Latest Revision'), Chris@0: 'help' => $this->t('Restrict the view to only revisions that are the latest revision of their entity.'), Chris@0: 'filter' => ['id' => 'latest_revision'], Chris@0: ]; Chris@18: if ($this->entityType->isTranslatable()) { Chris@18: $data[$revision_table]['latest_translation_affected_revision'] = [ Chris@18: 'title' => $this->t('Is Latest Translation Affected Revision'), Chris@18: 'help' => $this->t('Restrict the view to only revisions that are the latest translation affected revision of their entity.'), Chris@18: 'filter' => ['id' => 'latest_translation_affected_revision'], Chris@18: ]; Chris@18: } Chris@0: } Chris@0: Chris@0: $this->addEntityLinks($data[$base_table]); Chris@16: if ($views_revision_base_table) { Chris@16: $this->addEntityLinks($data[$views_revision_base_table]); Chris@16: } Chris@0: Chris@0: // Load all typed data definitions of all fields. This should cover each of Chris@0: // the entity base, revision, data tables. Chris@0: $field_definitions = $this->entityManager->getBaseFieldDefinitions($this->entityType->id()); Chris@0: /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ Chris@0: if ($table_mapping = $this->storage->getTableMapping($field_definitions)) { Chris@0: // Fetch all fields that can appear in both the base table and the data Chris@0: // table. Chris@0: $entity_keys = $this->entityType->getKeys(); Chris@0: $duplicate_fields = array_intersect_key($entity_keys, array_flip(['id', 'revision', 'bundle'])); Chris@0: // Iterate over each table we have so far and collect field data for each. Chris@0: // Based on whether the field is in the field_definitions provided by the Chris@0: // entity manager. Chris@0: // @todo We should better just rely on information coming from the entity Chris@0: // storage. Chris@0: // @todo https://www.drupal.org/node/2337511 Chris@0: foreach ($table_mapping->getTableNames() as $table) { Chris@0: foreach ($table_mapping->getFieldNames($table) as $field_name) { Chris@0: // To avoid confusing duplication in the user interface, for fields Chris@0: // that are on both base and data tables, only add them on the data Chris@0: // table (same for revision vs. revision data). Chris@0: if ($data_table && ($table === $base_table || $table === $revision_table) && in_array($field_name, $duplicate_fields)) { Chris@0: continue; Chris@0: } Chris@0: $this->mapFieldDefinition($table, $field_name, $field_definitions[$field_name], $table_mapping, $data[$table]); Chris@0: } Chris@0: } Chris@0: Chris@0: foreach ($field_definitions as $field_definition) { Chris@0: if ($table_mapping->requiresDedicatedTableStorage($field_definition->getFieldStorageDefinition())) { Chris@0: $table = $table_mapping->getDedicatedDataTableName($field_definition->getFieldStorageDefinition()); Chris@0: Chris@0: $data[$table]['table']['group'] = $this->entityType->getLabel(); Chris@0: $data[$table]['table']['provider'] = $this->entityType->getProvider(); Chris@0: $data[$table]['table']['join'][$views_base_table] = [ Chris@0: 'left_field' => $base_field, Chris@0: 'field' => 'entity_id', Chris@0: 'extra' => [ Chris@0: ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: if ($revisionable) { Chris@0: $revision_table = $table_mapping->getDedicatedRevisionTableName($field_definition->getFieldStorageDefinition()); Chris@0: Chris@0: $data[$revision_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]); Chris@0: $data[$revision_table]['table']['provider'] = $this->entityType->getProvider(); Chris@0: $data[$revision_table]['table']['join'][$views_revision_base_table] = [ Chris@0: 'left_field' => $revision_field, Chris@0: 'field' => 'entity_id', Chris@0: 'extra' => [ Chris@0: ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE], Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Add the entity type key to each table generated. Chris@0: $entity_type_id = $this->entityType->id(); Chris@0: array_walk($data, function (&$table_data) use ($entity_type_id) { Chris@0: $table_data['table']['entity type'] = $entity_type_id; Chris@0: }); Chris@0: Chris@0: return $data; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the entity links in case corresponding link templates exist. Chris@0: * Chris@0: * @param array $data Chris@0: * The views data of the base table. Chris@0: */ Chris@0: protected function addEntityLinks(array &$data) { Chris@0: $entity_type_id = $this->entityType->id(); Chris@0: $t_arguments = ['@entity_type_label' => $this->entityType->getLabel()]; Chris@0: if ($this->entityType->hasLinkTemplate('canonical')) { Chris@0: $data['view_' . $entity_type_id] = [ Chris@0: 'field' => [ Chris@0: 'title' => $this->t('Link to @entity_type_label', $t_arguments), Chris@0: 'help' => $this->t('Provide a view link to the @entity_type_label.', $t_arguments), Chris@0: 'id' => 'entity_link', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: if ($this->entityType->hasLinkTemplate('edit-form')) { Chris@0: $data['edit_' . $entity_type_id] = [ Chris@0: 'field' => [ Chris@0: 'title' => $this->t('Link to edit @entity_type_label', $t_arguments), Chris@0: 'help' => $this->t('Provide an edit link to the @entity_type_label.', $t_arguments), Chris@0: 'id' => 'entity_link_edit', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: if ($this->entityType->hasLinkTemplate('delete-form')) { Chris@0: $data['delete_' . $entity_type_id] = [ Chris@0: 'field' => [ Chris@0: 'title' => $this->t('Link to delete @entity_type_label', $t_arguments), Chris@0: 'help' => $this->t('Provide a delete link to the @entity_type_label.', $t_arguments), Chris@0: 'id' => 'entity_link_delete', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Puts the views data for a single field onto the views data. Chris@0: * Chris@0: * @param string $table Chris@0: * The table of the field to handle. Chris@0: * @param string $field_name Chris@0: * The name of the field to handle. Chris@0: * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition Chris@0: * The field definition defined in Entity::baseFieldDefinitions() Chris@0: * @param \Drupal\Core\Entity\Sql\TableMappingInterface $table_mapping Chris@0: * The table mapping information Chris@0: * @param array $table_data Chris@0: * A reference to a specific entity table (for example data_table) inside Chris@0: * the views data. Chris@0: */ Chris@0: protected function mapFieldDefinition($table, $field_name, FieldDefinitionInterface $field_definition, TableMappingInterface $table_mapping, &$table_data) { Chris@0: // Create a dummy instance to retrieve property definitions. Chris@0: $field_column_mapping = $table_mapping->getColumnNames($field_name); Chris@0: $field_schema = $this->getFieldStorageDefinitions()[$field_name]->getSchema(); Chris@0: Chris@0: $field_definition_type = $field_definition->getType(); Chris@0: // Add all properties to views table data. We need an entry for each Chris@0: // column of each field, with the first one given special treatment. Chris@0: // @todo Introduce concept of the "main" column for a field, rather than Chris@0: // assuming the first one is the main column. See also what the Chris@0: // mapSingleFieldViewsData() method does with $first. Chris@0: $first = TRUE; Chris@0: foreach ($field_column_mapping as $field_column_name => $schema_field_name) { Chris@14: $table_data[$schema_field_name] = $this->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition); Chris@14: $table_data[$schema_field_name]['entity field'] = $field_name; Chris@0: $first = FALSE; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Provides the views data for a given data type and schema field. Chris@0: * Chris@0: * @param string $table Chris@0: * The table of the field to handle. Chris@0: * @param string $field_name Chris@0: * The machine name of the field being processed. Chris@0: * @param string $field_type Chris@0: * The type of field being handled. Chris@0: * @param string $column_name Chris@0: * For fields containing multiple columns, the column name being processed. Chris@0: * @param string $column_type Chris@0: * Within the field, the column type being handled. Chris@0: * @param bool $first Chris@0: * TRUE if this is the first column within the field. Chris@0: * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition Chris@0: * The field definition. Chris@0: * Chris@0: * @return array Chris@0: * The modified views data field definition. Chris@0: */ Chris@0: protected function mapSingleFieldViewsData($table, $field_name, $field_type, $column_name, $column_type, $first, FieldDefinitionInterface $field_definition) { Chris@0: $views_field = []; Chris@0: Chris@0: // Provide a nicer, less verbose label for the first column within a field. Chris@0: // @todo Introduce concept of the "main" column for a field, rather than Chris@0: // assuming the first one is the main column. Chris@0: if ($first) { Chris@0: $views_field['title'] = $field_definition->getLabel(); Chris@0: } Chris@0: else { Chris@0: $views_field['title'] = $field_definition->getLabel() . " ($column_name)"; Chris@0: } Chris@0: Chris@0: if ($description = $field_definition->getDescription()) { Chris@0: $views_field['help'] = $description; Chris@0: } Chris@0: Chris@0: // Set up the field, sort, argument, and filters, based on Chris@0: // the column and/or field data type. Chris@0: // @todo Allow field types to customize this. Chris@0: // @see https://www.drupal.org/node/2337515 Chris@0: switch ($field_type) { Chris@0: // Special case a few field types. Chris@0: case 'timestamp': Chris@0: case 'created': Chris@0: case 'changed': Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'date'; Chris@0: $views_field['filter']['id'] = 'date'; Chris@0: $views_field['sort']['id'] = 'date'; Chris@0: break; Chris@0: Chris@0: case 'language': Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'language'; Chris@0: $views_field['filter']['id'] = 'language'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: break; Chris@0: Chris@0: case 'boolean': Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'numeric'; Chris@0: $views_field['filter']['id'] = 'boolean'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: break; Chris@0: Chris@0: case 'uri': Chris@0: // Let's render URIs as URIs by default, not links. Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['field']['default_formatter'] = 'string'; Chris@0: Chris@0: $views_field['argument']['id'] = 'string'; Chris@0: $views_field['filter']['id'] = 'string'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: break; Chris@0: Chris@0: case 'text': Chris@0: case 'text_with_summary': Chris@0: // Treat these three long text fields the same. Chris@0: $field_type = 'text_long'; Chris@0: // Intentional fall-through here to the default processing! Chris@0: Chris@0: default: Chris@0: // For most fields, the field type is generic enough to just use Chris@0: // the column type to determine the filters etc. Chris@0: switch ($column_type) { Chris@0: Chris@0: case 'int': Chris@0: case 'integer': Chris@0: case 'smallint': Chris@0: case 'tinyint': Chris@0: case 'mediumint': Chris@0: case 'float': Chris@0: case 'double': Chris@0: case 'decimal': Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'numeric'; Chris@0: $views_field['filter']['id'] = 'numeric'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: break; Chris@0: Chris@0: case 'char': Chris@0: case 'string': Chris@0: case 'varchar': Chris@0: case 'varchar_ascii': Chris@0: case 'tinytext': Chris@0: case 'text': Chris@0: case 'mediumtext': Chris@0: case 'longtext': Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'string'; Chris@0: $views_field['filter']['id'] = 'string'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: break; Chris@0: Chris@0: default: Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'standard'; Chris@0: $views_field['filter']['id'] = 'standard'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: } Chris@0: } Chris@0: Chris@0: // Do post-processing for a few field types. Chris@0: Chris@0: $process_method = 'processViewsDataFor' . Container::camelize($field_type); Chris@0: if (method_exists($this, $process_method)) { Chris@0: $this->{$process_method}($table, $field_definition, $views_field, $column_name); Chris@0: } Chris@0: Chris@0: return $views_field; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Processes the views data for a language field. Chris@0: * Chris@0: * @param string $table Chris@0: * The table the language field is added to. Chris@0: * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition Chris@0: * The field definition. Chris@0: * @param array $views_field Chris@0: * The views field data. Chris@0: * @param string $field_column_name Chris@0: * The field column being processed. Chris@0: */ Chris@0: protected function processViewsDataForLanguage($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name) { Chris@0: // Apply special titles for the langcode field. Chris@0: if ($field_definition->getName() == $this->entityType->getKey('langcode')) { Chris@0: if ($table == $this->entityType->getDataTable() || $table == $this->entityType->getRevisionDataTable()) { Chris@0: $views_field['title'] = $this->t('Translation language'); Chris@0: } Chris@0: if ($table == $this->entityType->getBaseTable() || $table == $this->entityType->getRevisionTable()) { Chris@0: $views_field['title'] = $this->t('Original language'); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Processes the views data for an entity reference field. Chris@0: * Chris@0: * @param string $table Chris@0: * The table the language field is added to. Chris@0: * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition Chris@0: * The field definition. Chris@0: * @param array $views_field Chris@0: * The views field data. Chris@0: * @param string $field_column_name Chris@0: * The field column being processed. Chris@0: */ Chris@0: protected function processViewsDataForEntityReference($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name) { Chris@0: Chris@0: // @todo Should the actual field handler respect that this just renders a Chris@0: // number? Chris@0: // @todo Create an optional entity field handler, that can render the Chris@0: // entity. Chris@0: // @see https://www.drupal.org/node/2322949 Chris@0: Chris@0: if ($entity_type_id = $field_definition->getItemDefinition()->getSetting('target_type')) { Chris@0: $entity_type = $this->entityManager->getDefinition($entity_type_id); Chris@0: if ($entity_type instanceof ContentEntityType) { Chris@0: $views_field['relationship'] = [ Chris@0: 'base' => $this->getViewsTableForEntityType($entity_type), Chris@0: 'base field' => $entity_type->getKey('id'), Chris@0: 'label' => $entity_type->getLabel(), Chris@0: 'title' => $entity_type->getLabel(), Chris@0: 'id' => 'standard', Chris@0: ]; Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'numeric'; Chris@0: $views_field['filter']['id'] = 'numeric'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: } Chris@0: else { Chris@0: $views_field['field']['id'] = 'field'; Chris@0: $views_field['argument']['id'] = 'string'; Chris@0: $views_field['filter']['id'] = 'string'; Chris@0: $views_field['sort']['id'] = 'standard'; Chris@0: } Chris@0: } Chris@0: Chris@0: if ($field_definition->getName() == $this->entityType->getKey('bundle')) { Chris@0: $views_field['filter']['id'] = 'bundle'; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Processes the views data for a text field with formatting. Chris@0: * Chris@0: * @param string $table Chris@0: * The table the field is added to. Chris@0: * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition Chris@0: * The field definition. Chris@0: * @param array $views_field Chris@0: * The views field data. Chris@0: * @param string $field_column_name Chris@0: * The field column being processed. Chris@0: */ Chris@0: protected function processViewsDataForTextLong($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name) { Chris@0: // Connect the text field to its formatter. Chris@0: if ($field_column_name == 'value') { Chris@0: $views_field['field']['format'] = $field_definition->getName() . '__format'; Chris@0: $views_field['field']['id'] = 'field'; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Processes the views data for a UUID field. Chris@0: * Chris@0: * @param string $table Chris@0: * The table the field is added to. Chris@0: * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition Chris@0: * The field definition. Chris@0: * @param array $views_field Chris@0: * The views field data. Chris@0: * @param string $field_column_name Chris@0: * The field column being processed. Chris@0: */ Chris@0: protected function processViewsDataForUuid($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name) { Chris@0: // It does not make sense for UUID fields to be click sortable. Chris@0: $views_field['field']['click sortable'] = FALSE; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getViewsTableForEntityType(EntityTypeInterface $entity_type) { Chris@0: return $entity_type->getDataTable() ?: $entity_type->getBaseTable(); Chris@0: } Chris@0: Chris@0: }