comparison core/modules/content_translation/src/ContentTranslationHandler.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
510 '#maxlength' => 25, 510 '#maxlength' => 25,
511 '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', ['%time' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date(REQUEST_TIME, 'custom', 'O')]), 511 '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', ['%time' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date(REQUEST_TIME, 'custom', 'O')]),
512 '#default_value' => $new_translation || !$date ? '' : format_date($date, 'custom', 'Y-m-d H:i:s O'), 512 '#default_value' => $new_translation || !$date ? '' : format_date($date, 'custom', 'Y-m-d H:i:s O'),
513 ]; 513 ];
514 514
515 if (isset($language_widget)) {
516 $language_widget['#multilingual'] = TRUE;
517 }
518
519 $form['#process'][] = [$this, 'entityFormSharedElements']; 515 $form['#process'][] = [$this, 'entityFormSharedElements'];
520 } 516 }
521 517
522 // Process the submitted values before they are stored. 518 // Process the submitted values before they are stored.
523 $form['#entity_builders'][] = [$this, 'entityFormEntityBuild']; 519 $form['#entity_builders'][] = [$this, 'entityFormEntityBuild'];
732 $entity_type_id => $entity->id(), 728 $entity_type_id => $entity->id(),
733 'source' => $source, 729 'source' => $source,
734 'target' => $form_object->getFormLangcode($form_state), 730 'target' => $form_object->getFormLangcode($form_state),
735 ]); 731 ]);
736 $languages = $this->languageManager->getLanguages(); 732 $languages = $this->languageManager->getLanguages();
737 drupal_set_message(t('Source language set to: %language', ['%language' => $languages[$source]->getName()])); 733 $this->messenger->addStatus(t('Source language set to: %language', ['%language' => $languages[$source]->getName()]));
738 } 734 }
739 735
740 /** 736 /**
741 * Form submission handler for ContentTranslationHandler::entityFormAlter(). 737 * Form submission handler for ContentTranslationHandler::entityFormAlter().
742 * 738 *
744 */ 740 */
745 public function entityFormDelete($form, FormStateInterface $form_state) { 741 public function entityFormDelete($form, FormStateInterface $form_state) {
746 $form_object = $form_state->getFormObject(); 742 $form_object = $form_state->getFormObject();
747 $entity = $form_object->getEntity(); 743 $entity = $form_object->getEntity();
748 if (count($entity->getTranslationLanguages()) > 1) { 744 if (count($entity->getTranslationLanguages()) > 1) {
749 drupal_set_message(t('This will delete all the translations of %label.', ['%label' => $entity->label()]), 'warning'); 745 $this->messenger->addWarning(t('This will delete all the translations of %label.', ['%label' => $entity->label()]));
750 } 746 }
751 } 747 }
752 748
753 /** 749 /**
754 * Form submission handler for ContentTranslationHandler::entityFormAlter(). 750 * Form submission handler for ContentTranslationHandler::entityFormAlter().