view modules/contrib/migrate_tools/src/Form/MigrationEditForm.php @ 9:1fc0ff908d1f

Add another data file
author Chris Cannam
date Mon, 05 Feb 2018 12:34:32 +0000
parents 4c8ae668cc8c
children
line wrap: on
line source
<?php

namespace Drupal\migrate_tools\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Class MigrationEditForm
 *
 * Provides the edit form for our Migration entity.
 *
 * @package Drupal\migrate_tools\Form
 *
 * @ingroup migrate_tools
 */
class MigrationEditForm extends MigrationFormBase {

  /**
   * Returns the actions provided by this form.
   *
   * For the edit form, we only need to change the text of the submit button.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   An associative array containing the current state of the form.
   *
   * @return array
   *   An array of supported actions for the current entity form.
   */
  public function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form, $form_state);
    $actions['submit']['#value'] = t('Update Migration');

    // Add the group parameter to the delete URL.
    $this->addGroupParameter($actions['delete']['#url'], $this->getEntity()->get('migration_group'));

    return $actions;
  }

  /**
   * @param \Drupal\Core\Url $url
   *   The URL associated with an operation.
   *
   * @param $migration_group
   *   The migration's parent group.
   */
  protected function addGroupParameter(Url $url, $migration_group) {
    $route_parameters = $url->getRouteParameters() + array('migration_group' => $migration_group);
    $url->setRouteParameters($route_parameters);
  }

}