You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.3 KiB

  1. <?php
  2. namespace Drupal\sample_migration\Form;
  3. use Drupal\Core\Form\FormBase;
  4. use Drupal\Core\Form\FormStateInterface;
  5. /**
  6. * Class TitleBodyParagraphForm.
  7. */
  8. class TitleBodyParagraphForm extends FormBase {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function getFormId() {
  13. return 'title_body_paragraph_form';
  14. }
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function buildForm(array $form, FormStateInterface $form_state) {
  19. $form['submit'] = [
  20. '#type' => 'submit',
  21. '#value' => $this->t('Submit'),
  22. ];
  23. return $form;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function validateForm(array &$form, FormStateInterface $form_state) {
  29. foreach ($form_state->getValues() as $key => $value) {
  30. // @TODO: Validate fields.
  31. }
  32. parent::validateForm($form, $form_state);
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function submitForm(array &$form, FormStateInterface $form_state) {
  38. $batch = [
  39. 'title' => $this->t('Bringing over Title Body Field Collections...'),
  40. 'operations' => [
  41. [
  42. 'sample_migration_title_body_paragraphs',
  43. [
  44. ]
  45. ]
  46. ],
  47. 'init_message' => $this->t('Loading nodes...'),
  48. 'progress_message' => $this->t('Processed @current out of @total'),
  49. 'finished' => $this->t('sample_migration_title_body_paragraphs_finished')
  50. ];
  51. batch_set($batch);
  52. }
  53. }