ProfileTranslationHandler
class ProfileTranslationHandler extends ContentTranslationHandler (View source)
Defines the translation handler for users.
Traits
Provides helper methods to detect changes in an entity object.
Provides dependency injection friendly methods for serialization.
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected string | $entityTypeId | The type of the entity being translated. |
from ContentTranslationHandler |
| protected EntityTypeInterface | $entityType | Information about the entity type. |
from ContentTranslationHandler |
| protected LanguageManagerInterface | $languageManager | The language manager. |
from ContentTranslationHandler |
| protected ContentTranslationManagerInterface | $manager | The content translation manager. |
from ContentTranslationHandler |
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
from ContentTranslationHandler |
| protected AccountInterface | $currentUser | The current user. |
from ContentTranslationHandler |
| protected FieldStorageDefinitionInterface[] | $fieldStorageDefinitions | The array of installed field storage definitions for the entity type, keyed by field name. |
from ContentTranslationHandler |
| protected MessengerInterface | $messenger | The messenger service. |
from ContentTranslationHandler |
| protected DateFormatterInterface | $dateFormatter | The date formatter service. |
from ContentTranslationHandler |
Methods
Returns an array of field names to skip when checking for changes.
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Initializes an instance of the content translation controller.
Instantiates a new instance of this entity handler.
Returns a set of field definitions to be used to store metadata items.
Checks whether the entity type supports author natively.
Checks whether the entity type supports published status natively.
Checks whether the entity type supports modification time natively.
Checks whether the entity type supports creation time natively.
Checks the field storage definition for translatability support.
Checks if the user can perform the given operation on translations of the wrapped entity.
Retrieves the source language for the translation being created.
Performs the needed alterations to the entity form.
Process callback: determines which elements get clue in the form.
Adds a clue about the form element translatability.
Entity builder method.
Form validation handler for ContentTranslationHandler::entityFormAlter().
Form submission handler for ContentTranslationHandler::entityFormAlter().
Form submission handler for ContentTranslationHandler::entityFormAlter().
Form submission handler for ContentTranslationHandler::entityFormAlter().
Form submission handler for ContentTranslationHandler::entityFormAlter().
Default value callback for the owner base field definition.
Form submission handler for ProfileTranslationHandler::entityFormAlter().
Details
protected string[]
getFieldsToSkipFromTranslationChangesCheck(ContentEntityInterface $entity)
Returns an array of field names to skip when checking for changes.
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
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
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__construct(EntityTypeInterface $entity_type, LanguageManagerInterface $language_manager, ContentTranslationManagerInterface $manager, EntityTypeManagerInterface $entity_type_manager, AccountInterface $current_user, MessengerInterface $messenger, DateFormatterInterface $date_formatter, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository)
Initializes an instance of the content translation controller.
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.
FieldDefinitionInterface[]
getFieldDefinitions()
Returns a set of field definitions to be used to store metadata items.
protected bool
hasAuthor()
Checks whether the entity type supports author natively.
protected bool
hasPublishedStatus()
Checks whether the entity type supports published status natively.
protected bool
hasChangedTime()
Checks whether the entity type supports modification time natively.
protected bool
hasCreatedTime()
Checks whether the entity type supports creation time natively.
protected bool
checkFieldStorageDefinitionTranslatability(string $field_name)
Checks the field storage definition for translatability support.
Checks whether the given field is defined in the field storage definitions and if its definition specifies it as translatable.
retranslate(EntityInterface $entity, string $langcode = NULL)
Marks translations as outdated.
AccessResultInterface
getTranslationAccess(EntityInterface $entity, $op)
Checks if the user can perform the given operation on translations of the wrapped entity.
string
getSourceLangcode(FormStateInterface $form_state)
Retrieves the source language for the translation being created.
entityFormAlter(array $form, FormStateInterface $form_state, EntityInterface $entity)
Performs the needed alterations to the entity form.
entityFormSharedElements($element, FormStateInterface $form_state, $form)
Process callback: determines which elements get clue in the form.
protected
addTranslatabilityClue(array $element)
Adds a clue about the form element translatability.
If the given element does not have a #title attribute, the function is recursively applied to child elements.
entityFormEntityBuild(string $entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
Entity builder method.
entityFormValidate($form, FormStateInterface $form_state)
Form validation handler for ContentTranslationHandler::entityFormAlter().
Validates the submitted content translation metadata.
entityFormSubmit($form, FormStateInterface $form_state)
Form submission handler for ContentTranslationHandler::entityFormAlter().
Updates metadata fields, which should be updated only after the validation has run and before the entity is saved.
entityFormSourceChange($form, FormStateInterface $form_state)
Form submission handler for ContentTranslationHandler::entityFormAlter().
Takes care of the source language change.
entityFormDelete($form, FormStateInterface $form_state)
Form submission handler for ContentTranslationHandler::entityFormAlter().
Takes care of entity deletion.
entityFormDeleteTranslation($form, FormStateInterface $form_state)
Form submission handler for ContentTranslationHandler::entityFormAlter().
Takes care of content translation deletion.
protected string|null
entityFormTitle(EntityInterface $entity)
Returns the title to be used for the entity form page.
static int
getDefaultOwnerId()
Default value callback for the owner base field definition.
entityFormSave(array $form, FormStateInterface $form_state)
Form submission handler for ProfileTranslationHandler::entityFormAlter().
This handles the save action.