class UserViewsData extends EntityViewsData (View source)

Provides the views data for the user entity type.

Traits

Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.

Properties

protected TranslationInterface $stringTranslation

The string translation service.

from  StringTranslationTrait
protected EntityTypeInterface $entityType

Entity type for this views data handler instance.

from  EntityViewsData
protected SqlEntityStorageInterface $storage

The storage used for this entity type.

from  EntityViewsData
protected ModuleHandlerInterface $moduleHandler

The module handler.

from  EntityViewsData
protected TranslationInterface $translationManager

The translation manager.

from  EntityViewsData
protected FieldStorageDefinitionInterface[] $fieldStorageDefinitions

The field storage definitions for all base fields of the entity type.

from  EntityViewsData
protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

from  EntityViewsData
protected EntityFieldManagerInterface $entityFieldManager

The entity field manager.

from  EntityViewsData

Methods

t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

getStringTranslation()

Gets the string translation service.

$this
setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

__construct(EntityTypeInterface $entity_type, SqlEntityStorageInterface $storage_controller, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, TranslationInterface $translation_manager, EntityFieldManagerInterface $entity_field_manager)

Constructs an EntityViewsData object.

createInstance(ContainerInterface $container, EntityTypeInterface $entity_type)

Instantiates a new instance of this entity handler.

getFieldStorageDefinitions()

Gets the field storage definitions.

array
getViewsData()

Returns views data for the entity type.

addEntityLinks(array $data)

Sets the entity links in case corresponding link templates exist.

mapFieldDefinition(string $table, string $field_name, FieldDefinitionInterface $field_definition, TableMappingInterface $table_mapping, array $table_data)

Puts the views data for a single field onto the views data.

array
mapSingleFieldViewsData(string $table, string $field_name, string $field_type, string $column_name, string $column_type, bool $first, FieldDefinitionInterface $field_definition)

Provides the views data for a given data type and schema field.

processViewsDataForLanguage(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for a language field.

processViewsDataForEntityReference(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for an entity reference field.

processViewsDataForTextLong(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for a text field with formatting.

processViewsDataForUuid(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for a UUID field.

string
getViewsTableForEntityType(EntityTypeInterface $entity_type)

Gets the table of an entity type to be used as base table in views.

Details

protected TranslatableMarkup t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.

In order for strings to be localized, make them available in one of the ways supported by the

Parameters

string $string

A string containing the English text to translate.

array $args

(optional) An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for details.

array $options

(optional) An associative array of additional options, with the following elements:

  • 'langcode' (defaults to the current language): A language code, to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to. See the @link i18n Internationalization topic @endlink for more information about string contexts.

Return Value

TranslatableMarkup

An object that, when cast to a string, returns the translated string.

See also

FormattableMarkup::placeholderFormat
TranslatableMarkup::__construct

protected formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

Parameters

$count
$singular
$plural
array $args
array $options

See also

TranslationInterface::formatPlural

protected getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

Parameters

$langcode

See also

PluralFormulaInterface::getNumberOfPlurals

protected TranslationInterface getStringTranslation()

Gets the string translation service.

Return Value

TranslationInterface

The string translation service.

$this setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

Parameters

TranslationInterface $translation

The string translation service.

Return Value

$this

__construct(EntityTypeInterface $entity_type, SqlEntityStorageInterface $storage_controller, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, TranslationInterface $translation_manager, EntityFieldManagerInterface $entity_field_manager)

Constructs an EntityViewsData object.

Parameters

EntityTypeInterface $entity_type

The entity type to provide views integration for.

SqlEntityStorageInterface $storage_controller

The storage handler used for this entity type.

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

ModuleHandlerInterface $module_handler

The module handler.

TranslationInterface $translation_manager

The translation manager.

EntityFieldManagerInterface $entity_field_manager

The entity field manager.

static EntityHandlerInterface createInstance(ContainerInterface $container, EntityTypeInterface $entity_type)

Instantiates a new instance of this entity handler.

This is a factory method that returns a new instance of this object. The factory should pass any needed dependencies into the constructor of this object, but not the container itself. Every call to this method must return a new instance of this object; that is, it may not implement a singleton.

Parameters

ContainerInterface $container

The service container this object should use.

EntityTypeInterface $entity_type

The entity type definition.

Return Value

EntityHandlerInterface

A new instance of the entity handler.

protected FieldStorageDefinitionInterface[] getFieldStorageDefinitions()

Gets the field storage definitions.

array getViewsData()

Returns views data for the entity type.

Return Value

array

Views data in the format of hook_views_data().

Sets the entity links in case corresponding link templates exist.

Parameters

array $data

The views data of the base table.

protected mapFieldDefinition(string $table, string $field_name, FieldDefinitionInterface $field_definition, TableMappingInterface $table_mapping, array $table_data)

Puts the views data for a single field onto the views data.

Parameters

string $table

The table of the field to handle.

string $field_name

The name of the field to handle.

FieldDefinitionInterface $field_definition

The field definition defined in Entity::baseFieldDefinitions()

TableMappingInterface $table_mapping

The table mapping information

array $table_data

A reference to a specific entity table (for example data_table) inside the views data.

protected array mapSingleFieldViewsData(string $table, string $field_name, string $field_type, string $column_name, string $column_type, bool $first, FieldDefinitionInterface $field_definition)

Provides the views data for a given data type and schema field.

Parameters

string $table

The table of the field to handle.

string $field_name

The machine name of the field being processed.

string $field_type

The type of field being handled.

string $column_name

For fields containing multiple columns, the column name being processed.

string $column_type

Within the field, the column type being handled.

bool $first

TRUE if this is the first column within the field.

FieldDefinitionInterface $field_definition

The field definition.

Return Value

array

The modified views data field definition.

protected processViewsDataForLanguage(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for a language field.

Parameters

string $table

The table the language field is added to.

FieldDefinitionInterface $field_definition

The field definition.

array $views_field

The views field data.

string $field_column_name

The field column being processed.

protected processViewsDataForEntityReference(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for an entity reference field.

Parameters

string $table

The table the language field is added to.

FieldDefinitionInterface $field_definition

The field definition.

array $views_field

The views field data.

string $field_column_name

The field column being processed.

protected processViewsDataForTextLong(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for a text field with formatting.

Parameters

string $table

The table the field is added to.

FieldDefinitionInterface $field_definition

The field definition.

array $views_field

The views field data.

string $field_column_name

The field column being processed.

protected processViewsDataForUuid(string $table, FieldDefinitionInterface $field_definition, array $views_field, string $field_column_name)

Processes the views data for a UUID field.

Parameters

string $table

The table the field is added to.

FieldDefinitionInterface $field_definition

The field definition.

array $views_field

The views field data.

string $field_column_name

The field column being processed.

string getViewsTableForEntityType(EntityTypeInterface $entity_type)

Gets the table of an entity type to be used as base table in views.

Parameters

EntityTypeInterface $entity_type

The entity type.

Return Value

string

The name of the base table in views.