function ContentTranslationHandler::__construct

Same name in other branches
  1. 9 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::__construct()
  2. 8.9.x core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::__construct()
  3. 11.x core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::__construct()

Initializes an instance of the content translation controller.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The info array of the given entity type.

\Drupal\Core\Language\LanguageManagerInterface $language_manager: The language manager.

\Drupal\content_translation\ContentTranslationManagerInterface $manager: The content translation manager service.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

\Drupal\Core\Session\AccountInterface $current_user: The current user.

\Drupal\Core\Messenger\MessengerInterface $messenger: The messenger service.

\Drupal\Core\Datetime\DateFormatterInterface $date_formatter: The date formatter service.

\Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository: The installed entity definition repository service.

\Drupal\Core\Routing\RedirectDestinationInterface|null $redirectDestination: The request stack.

\Drupal\Component\Datetime\TimeInterface|null $time: The time service.

File

core/modules/content_translation/src/ContentTranslationHandler.php, line 130

Class

ContentTranslationHandler
Base class for content translation handlers.

Namespace

Drupal\content_translation

Code

public function __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, ?RedirectDestinationInterface $redirectDestination = NULL, ?TimeInterface $time = NULL) {
    $this->entityTypeId = $entity_type->id();
    $this->entityType = $entity_type;
    $this->languageManager = $language_manager;
    $this->manager = $manager;
    $this->entityTypeManager = $entity_type_manager;
    $this->currentUser = $current_user;
    $this->fieldStorageDefinitions = $entity_last_installed_schema_repository->getLastInstalledFieldStorageDefinitions($this->entityTypeId);
    $this->messenger = $messenger;
    $this->dateFormatter = $date_formatter;
    if ($this->redirectDestination === NULL) {
        @trigger_error('Calling ContentTranslationHandler::__construct() without the $redirectDestination argument is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3375487', E_USER_DEPRECATED);
        $this->redirectDestination = \Drupal::service('redirect.destination');
    }
    if ($this->time === NULL) {
        @trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3112298', E_USER_DEPRECATED);
        $this->time = \Drupal::service('datetime.time');
    }
}

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