/** * {@inheritdoc} */ protected function init(FormStateInterface $form_state) { $comment = $this->entity; // Make the comment inherit the current content language unless specifically // set. if ($comment->isNew()) { $language_content = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); $comment->langcode->value = $language_content->getId(); } parent::init($form_state); }
/** * {@inheritdoc} */ protected function init(array &$form_state) { $message = $this->entity; // Make the message inherit the current content language unless specifically // set. if ($message->isNew() && !$message->langcode->value) { $language_content = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); $message->langcode->value = $language_content->id; } parent::init($form_state); }