class ProfileTranslationHandler

Same name in other branches
  1. 9 core/modules/user/src/ProfileTranslationHandler.php \Drupal\user\ProfileTranslationHandler
  2. 8.9.x core/modules/user/src/ProfileTranslationHandler.php \Drupal\user\ProfileTranslationHandler
  3. 11.x core/modules/user/src/ProfileTranslationHandler.php \Drupal\user\ProfileTranslationHandler

Defines the translation handler for users.

Hierarchy

Expanded class hierarchy of ProfileTranslationHandler

File

core/modules/user/src/ProfileTranslationHandler.php, line 12

Namespace

Drupal\user
View source
class ProfileTranslationHandler extends ContentTranslationHandler {
    
    /**
     * {@inheritdoc}
     */
    protected function hasPublishedStatus() {
        // User status has nothing to do with translations visibility.
        return FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function hasCreatedTime() {
        // User creation date has nothing to do with translation creation date.
        return FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) {
        parent::entityFormAlter($form, $form_state, $entity);
        $form['actions']['submit']['#submit'][] = [
            $this,
            'entityFormSave',
        ];
    }
    
    /**
     * Form submission handler for ProfileTranslationHandler::entityFormAlter().
     *
     * This handles the save action.
     *
     * @see \Drupal\Core\Entity\EntityForm::build()
     */
    public function entityFormSave(array $form, FormStateInterface $form_state) {
        if ($this->getSourceLangcode($form_state)) {
            $entity = $form_state->getFormObject()
                ->getEntity();
            // We need a redirect here, otherwise we would get an access denied page
            // since the current URL would be preserved and we would try to add a
            // translation for a language that already has a translation.
            $form_state->setRedirectUrl($entity->toUrl());
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ContentTranslationHandler::$currentUser protected property The current user.
ContentTranslationHandler::$dateFormatter protected property The date formatter service.
ContentTranslationHandler::$entityType protected property Information about the entity type.
ContentTranslationHandler::$entityTypeId protected property The type of the entity being translated.
ContentTranslationHandler::$entityTypeManager protected property The entity type manager.
ContentTranslationHandler::$fieldStorageDefinitions protected property Installed field storage definitions for the entity type.
ContentTranslationHandler::$languageManager protected property The language manager.
ContentTranslationHandler::$manager protected property The content translation manager.
ContentTranslationHandler::$messenger protected property The messenger service.
ContentTranslationHandler::addTranslatabilityClue protected function Adds a clue about the form element translatability.
ContentTranslationHandler::checkFieldStorageDefinitionTranslatability protected function Checks the field storage definition for translatability support.
ContentTranslationHandler::createInstance public static function Overrides EntityHandlerInterface::createInstance
ContentTranslationHandler::entityFormDelete public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormDeleteTranslation public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormDeleteTranslationUrl protected function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormEntityBuild public function Entity builder method. 3
ContentTranslationHandler::entityFormSharedElements public function Process callback: determines which elements get clue in the form.
ContentTranslationHandler::entityFormSourceChange public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormSubmit public function Form submission handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::entityFormTitle protected function Returns the title to be used for the entity form page. 3
ContentTranslationHandler::entityFormValidate public function Form validation handler for ContentTranslationHandler::entityFormAlter().
ContentTranslationHandler::getDefaultOwnerId public static function Default value callback for the owner base field definition.
ContentTranslationHandler::getFieldDefinitions public function Overrides ContentTranslationHandlerInterface::getFieldDefinitions
ContentTranslationHandler::getSourceLangcode public function Overrides ContentTranslationHandlerInterface::getSourceLangcode
ContentTranslationHandler::getTranslationAccess public function Overrides ContentTranslationHandlerInterface::getTranslationAccess
ContentTranslationHandler::hasAuthor protected function Checks whether the entity type supports author natively.
ContentTranslationHandler::hasChangedTime protected function Checks whether the entity type supports modification time natively.
ContentTranslationHandler::retranslate public function Overrides ContentTranslationHandlerInterface::retranslate
ContentTranslationHandler::__construct public function Initializes an instance of the content translation controller.
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes.
ProfileTranslationHandler::entityFormAlter public function Overrides ContentTranslationHandler::entityFormAlter
ProfileTranslationHandler::entityFormSave public function Form submission handler for ProfileTranslationHandler::entityFormAlter().
ProfileTranslationHandler::hasCreatedTime protected function Overrides ContentTranslationHandler::hasCreatedTime
ProfileTranslationHandler::hasPublishedStatus protected function Overrides ContentTranslationHandler::hasPublishedStatus
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.