reverted: --- b/migrate_ui.routing.yml +++ a/migrate_ui.routing.yml @@ -45,11 +45,3 @@ _title: 'Delete migration' requirements: _entity_access: 'migration.delete' - -entity.migration.launch_form: - path: '/admin/config/migrate/migrations/launch/{migration}' - defaults: - _entity_form: 'migration.launch-form' - _title: 'Launch migration' - requirements: - _entity_access: 'migration.launch' \ No newline at end of file diff -u b/src/Form/LaunchMigrationForm.php b/src/Form/LaunchMigrationForm.php --- b/src/Form/LaunchMigrationForm.php +++ b/src/Form/LaunchMigrationForm.php @@ -2,48 +2,45 @@ /** * @file - * Contains \Drupal\migrate_ui\Form\ProcessMigrationForm + * Contains \Drupal\migrate_tools\Form\LaunchMigrationForm */ -namespace Drupal\migrate_ui\Form; +namespace Drupal\migrate_tools\Form; -use Drupal\Component\Utility\SortArray; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; -use Drupal\migrate\Entity\MigrationInterface; -use Drupal\migrate\Plugin\migrate\process\Migration; +use Drupal\Core\Form\FormBase; +use Drupal\migrate\Plugin\MigrationInterface; /** * This form is specifically for configuring process pipelines. */ -class LaunchMigrationForm extends MigrationEntityFormBase { - +class LaunchMigrationForm extends FormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $destination_field = NULL) { - $this->destinationField = $destination_field; - return parent::buildForm($form, $form_state); + public function getFormId() { + return 'launch_migration_form'; } /** * {@inheritdoc} */ - public function form(array $form, FormStateInterface $form_state) { - $form = parent::form($form, $form_state); + public function buildForm(array $form, FormStateInterface $form_state) { + + $form = array(); - $form['operations'] = $this->migrateUiMigrateOperations(); + $form['operations'] = $this->migrateMigrateOperations(); return $form; } - /** * Get Operations. */ - private function migrateUiMigrateOperations() { + private function migrateMigrateOperations() { // Build the 'Update options' form. $operations = array( '#type' => 'fieldset', @@ -72,8 +69,6 @@ $operations['submit'] = array( '#type' => 'submit', '#value' => t('Execute'), - '#validate' => array('migrate_ui_migrate_validate'), - '#submit' => array('migrate_ui_migrate_submit'), ); $operations['description'] = array( '#prefix' => '

', @@ -143,12 +138,10 @@ * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { - if (empty($form_state->getValue('operation'))) { $form_state->setErrorByName('operation', $this->t('Please select an operation.')); return; } - } /** @@ -174,24 +167,24 @@ } $migration_name = \Drupal::routeMatch()->getParameter('migration'); - $machine_name = $migration_name->id(); + $machine_name = $migration_name; $operations = array(); $drush_arguments = array(); - if ($machine_name) { + if ($migration_name) { //TODO $migration = Migration::getInstance($machine_name); //TODO if ($migration) { switch ($operation) { case 'import_immediate': // Update (if necessary) once, before starting - if ($update && method_exists($migration, 'prepareUpdate')) { - //TODO $migration->prepareUpdate(); - } - $operations[] = array('migrate_ui_batch', array('import', $machine_name, $limit, $force)); + /*if ($update && method_exists($migration, 'prepareUpdate')) { + $migration->prepareUpdate(); + }*/ + $operations[] = array('drush_migrate_tools_migrate_import', array($machine_name, $limit, $force)); break; case 'rollback_immediate': - $operations[] = array('migrate_ui_batch', array('rollback', $machine_name, $limit, $force)); + $operations[] = array('drush_migrate_tools_migrate_rollback', array($machine_name, $limit, $force)); break; case 'import_background': case 'rollback_background': @@ -204,7 +197,7 @@ //$migration->resetStatus(); break; case 'deregister': - //migrate_ui_deregister_migration($machine_name); + //migrate_tools_deregister_migration($machine_name); break; //TODO} } @@ -216,19 +209,18 @@ $batch = array( 'operations' => $operations, 'title' => t('Import processing'), - 'file' => drupal_get_path('module', 'migrate_ui') . '/migrate_ui.pages.inc', + 'file' => drupal_get_path('module', 'migrate_tools') . '/migrate_tools.drush.inc', 'init_message' => t('Starting import process'), 'progress_message' => t(''), 'error_message' => t('An error occurred. Some or all of the import processing has failed.'), 'finished' => 'migrate_ui_batch_finish', ); batch_set($batch); - } elseif (count($drush_arguments) > 0) { - kint('la'); - trim(variable_get('migrate_drush_path', '')); - // Check that $drush_path works. See migrate_ui_configure_form(). + + $drush_path = trim(variable_get('migrate_drush_path', '')); + // Check that $drush_path works. See migrate_tools_configure_form(). if (!is_executable($drush_path)) { $message = t('To enable running operations in the background with drush, (which is recommended), some configuration must be done on the server. See the documentation on drupal.org.', array( @@ -241,8 +233,8 @@ drupal_set_message($message); return; } - $uri = $GLOBALS['base_url']; - $uid = $GLOBALS['user']->uid; + $uri = \Drupal::request()->getHost(); + $uid = $user = \Drupal::currentUser()->id(); if ($operation == 'import_background') { $command = 'mi'; $log_suffix = '.import.log'; reverted: --- b/src/MigrationListBuilder.php +++ a/src/MigrationListBuilder.php @@ -59,8 +59,6 @@ $row['destination'] = $this->t('Destination name'); $row['tags'] = $this->t('Tags'); $row['operations'] = $this->t('Operations'); - $row['import'] = $this->t('Import'); - return $row; } @@ -74,15 +72,6 @@ $row['destination']['data'] = $entity->getDestinationPlugin()->getPluginId(); $row['tags']['data'] = implode(', ', $entity->get('migration_tags') ?: []); $row['operations']['data'] = $this->buildOperations($entity); - $row['import']['data'] = array( - '#type' => 'dropbutton', - '#links' => array( - 'simple_form' => array( - 'title' => $this->t('Launch'), - 'url' => Url::fromRoute('entity.migration.launch_form', array('migration' => $entity->get('id'))), - ), - ), - ); return $row; } only in patch2: unchanged: --- a/migrate_tools.routing.yml +++ b/migrate_tools.routing.yml @@ -77,3 +77,11 @@ migrate_tools.messages: _title: 'Messages' requirements: _permission: 'administer migrations' + +migrate_tools.launch: + path: '/admin/structure/migrate/manage/{migration_group}/migrations/{migration}/launch' + defaults: + _form: '\Drupal\migrate_tools\Form\LaunchMigrationForm' + _title: 'Launch migration' + requirements: + _permission: 'administer migrations' only in patch2: unchanged: --- a/src/Controller/MigrationListBuilder.php +++ b/src/Controller/MigrationListBuilder.php @@ -83,6 +83,7 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand $header['unprocessed'] = $this->t('Unprocessed'); $header['messages'] = $this->t('Messages'); $header['last_imported'] = $this->t('Last Imported'); + $header['operations'] = $this->t('Operations'); return $header; // + parent::buildHeader(); } @@ -142,6 +143,15 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand else { $row['last_imported'] = ''; } + $row['operations']['data'] = array( + '#type' => 'dropbutton', + '#links' => array( + 'simple_form' => array( + 'title' => $this->t('Launch'), + 'url' => Url::fromRoute('migrate_tools.launch', array('migration_group' => $migration_group, 'migration' => $migration->id())), + ), + ), + ); return $row + parent::buildRow($migration_entity); }