コード例 #1
0
 /**
  * {@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);
 }
コード例 #2
0
ファイル: MessageForm.php プロジェクト: alnutile/drunatra
 /**
  * {@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);
 }