Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\migrate_tools\Form;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Form\FormStateInterface;
|
Chris@0
|
6 use Drupal\Core\Url;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Class MigrationEditForm
|
Chris@0
|
10 *
|
Chris@0
|
11 * Provides the edit form for our Migration entity.
|
Chris@0
|
12 *
|
Chris@0
|
13 * @package Drupal\migrate_tools\Form
|
Chris@0
|
14 *
|
Chris@0
|
15 * @ingroup migrate_tools
|
Chris@0
|
16 */
|
Chris@0
|
17 class MigrationEditForm extends MigrationFormBase {
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * Returns the actions provided by this form.
|
Chris@0
|
21 *
|
Chris@0
|
22 * For the edit form, we only need to change the text of the submit button.
|
Chris@0
|
23 *
|
Chris@0
|
24 * @param array $form
|
Chris@0
|
25 * An associative array containing the structure of the form.
|
Chris@0
|
26 * @param \Drupal\Core\Form\FormStateInterface $form_state
|
Chris@0
|
27 * An associative array containing the current state of the form.
|
Chris@0
|
28 *
|
Chris@0
|
29 * @return array
|
Chris@0
|
30 * An array of supported actions for the current entity form.
|
Chris@0
|
31 */
|
Chris@0
|
32 public function actions(array $form, FormStateInterface $form_state) {
|
Chris@0
|
33 $actions = parent::actions($form, $form_state);
|
Chris@0
|
34 $actions['submit']['#value'] = t('Update Migration');
|
Chris@0
|
35
|
Chris@0
|
36 // Add the group parameter to the delete URL.
|
Chris@0
|
37 $this->addGroupParameter($actions['delete']['#url'], $this->getEntity()->get('migration_group'));
|
Chris@0
|
38
|
Chris@0
|
39 return $actions;
|
Chris@0
|
40 }
|
Chris@0
|
41
|
Chris@0
|
42 /**
|
Chris@0
|
43 * @param \Drupal\Core\Url $url
|
Chris@0
|
44 * The URL associated with an operation.
|
Chris@0
|
45 *
|
Chris@0
|
46 * @param $migration_group
|
Chris@0
|
47 * The migration's parent group.
|
Chris@0
|
48 */
|
Chris@0
|
49 protected function addGroupParameter(Url $url, $migration_group) {
|
Chris@0
|
50 $route_parameters = $url->getRouteParameters() + array('migration_group' => $migration_group);
|
Chris@0
|
51 $url->setRouteParameters($route_parameters);
|
Chris@0
|
52 }
|
Chris@0
|
53
|
Chris@0
|
54 }
|