diff --git a/src/Form/MigrateUpgradeForm.php b/src/Form/MigrateUpgradeForm.php index 72f1092..416886c 100644 --- a/src/Form/MigrateUpgradeForm.php +++ b/src/Form/MigrateUpgradeForm.php @@ -39,9 +39,9 @@ class MigrateUpgradeForm extends ConfirmFormBase { /** * Mapping of known migrations and their source and destination modules. * - * @todo Hardcoding this information is not robust - the migrations - * themselves should hold the necessary information. - * @see https://www.drupal.org/node/2569805 + * @todo https://www.drupal.org/node/2569805 Hardcoding this information is + * not robust - the migrations themselves should hold the necessary + * information. * * @var array[] */ @@ -597,21 +597,29 @@ class MigrateUpgradeForm extends ConfirmFormBase { ]; /** + * The state service. + * * @var \Drupal\Core\State\StateInterface */ protected $state; /** + * The date formatter service. + * * @var \Drupal\Core\Datetime\DateFormatterInterface */ protected $dateFormatter; /** + * The renderer service. + * * @var \Drupal\Core\Render\RendererInterface */ protected $renderer; /** + * The migration entity storage. + * * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $entityStorage; @@ -620,9 +628,13 @@ class MigrateUpgradeForm extends ConfirmFormBase { * MigrateUpgradeForm constructor. * * @param \Drupal\Core\State\StateInterface $state + * The state service. * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter + * The date formatter service. * @param \Drupal\Core\Render\RendererInterface $renderer + * The renderer service. * @param \Drupal\Core\Entity\EntityStorageInterface $entity_storage + * The migration entity storage. */ public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, EntityStorageInterface $entity_storage) { $this->state = $state; @@ -786,6 +798,9 @@ class MigrateUpgradeForm extends ConfirmFormBase { * * @return array * The form structure. + * + * @todo Private files directory not yet implemented, depends on + * https://www.drupal.org/node/2547125. */ public function buildCredentialForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Drupal Upgrade'); @@ -860,15 +875,6 @@ class MigrateUpgradeForm extends ConfirmFormBase { '#description' => $this->t('To import files from your current Drupal site, enter a local file directory containing your site (e.g. /var/www/docroot), or your site address (e.g. http://example.com).'), ]; - /* - // @todo Not yet implemented, depends on https://www.drupal.org/node/2547125. - $form['files']['private_file_directory'] = [ - '#type' => 'textfield', - '#title' => $this->t('Private file path'), - '#description' => $this->t('To import private files from your current Drupal site, enter a local file directory containing your files (e.g. /var/private_files).'), - ]; - */ - $form['actions'] = ['#type' => 'actions']; $form['actions']['save'] = [ '#type' => 'submit', @@ -1085,7 +1091,7 @@ class MigrateUpgradeForm extends ConfirmFormBase { foreach ($destination_module_info as $destination_module => $migration_ids) { $destination_details[$destination_module] = [ '#type' => 'item', - '#plain_text' => $this->t($destination_module), + '#plain_text' => $destination_module, ]; } $form['available_module_list']['module_list'][$source_module] = [ diff --git a/src/MigrateMessageCapture.php b/src/MigrateMessageCapture.php index 3ccef90..cb5fdcd 100644 --- a/src/MigrateMessageCapture.php +++ b/src/MigrateMessageCapture.php @@ -39,6 +39,7 @@ class MigrateMessageCapture implements MigrateMessageInterface { * Returns any captured messages. * * @return array + * The captured messages. */ public function getMessages() { return $this->messages; diff --git a/src/MigrateUpgradeRunBatch.php b/src/MigrateUpgradeRunBatch.php index 72dfdc1..5809176 100644 --- a/src/MigrateUpgradeRunBatch.php +++ b/src/MigrateUpgradeRunBatch.php @@ -19,6 +19,9 @@ use Drupal\migrate\Event\MigratePostRowSaveEvent; use Drupal\migrate\Event\MigrateRowDeleteEvent; use Drupal\migrate\MigrateExecutable; +/** + * Runs a single migration batch. + */ class MigrateUpgradeRunBatch { /** @@ -60,7 +63,7 @@ class MigrateUpgradeRunBatch { * @param int[] $initial_ids * The full set of migration IDs to import. * @param string $operation - * 'import' or 'rollback'. + * The operation to perform, 'import' or 'rollback'. * @param array $context * The batch context. */ @@ -111,7 +114,7 @@ class MigrateUpgradeRunBatch { $migration_name = $migration->label() ? $migration->label() : $migration_id; - try { + try { if ($operation == 'import') { $migration_status = $executable->import(); } @@ -188,7 +191,7 @@ class MigrateUpgradeRunBatch { $message_count = count($context['sandbox']['messages']); $context['message'] = ''; for ($index = max(0, $message_count - self::MESSAGE_LENGTH); $index < $message_count; $index++) { - $context['message'] = $context['sandbox']['messages'][$index]. "
\n" . $context['message']; + $context['message'] = $context['sandbox']['messages'][$index] . "
\n" . $context['message']; } if ($message_count > self::MESSAGE_LENGTH) { // Indicate there are earlier messages not displayed. @@ -284,8 +287,8 @@ class MigrateUpgradeRunBatch { } else { if ($results['operation'] == 'import') { - // Everything went off without a hitch. We may not have had successes but - // we didn't have failures so this is fine. + // Everything went off without a hitch. We may not have had successes + // but we didn't have failures so this is fine. drupal_set_message(t('Congratulations, you upgraded Drupal!')); } else { diff --git a/src/MigrationCreationTrait.php b/src/MigrationCreationTrait.php index 98a56da..3845449 100644 --- a/src/MigrationCreationTrait.php +++ b/src/MigrationCreationTrait.php @@ -20,12 +20,13 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException; trait MigrationCreationTrait { /** - * Get the database connection for the source Drupal database. + * Gets the database connection for the source Drupal database. * * @param array $database * Database array representing the source Drupal database. * * @return \Drupal\Core\Database\Connection + * The database connection for the source Drupal database. */ protected function getConnection(array $database) { // Set up the connection. @@ -35,19 +36,20 @@ trait MigrationCreationTrait { } /** - * Get the system data from the system table of the source Drupal database. + * Gets the system data from the system table of the source Drupal database. * * @param array $database * Database array representing the source Drupal database. * * @return array + * The system data from the system table of the source Drupal database. */ protected function getSystemData(array $database) { $connection = $this->getConnection($database); $system_data = []; try { $results = $connection->select('system', 's', [ - 'fetch' => \PDO::FETCH_ASSOC + 'fetch' => \PDO::FETCH_ASSOC, ]) ->fields('s') ->execute(); @@ -104,12 +106,16 @@ trait MigrationCreationTrait { } /** - * Gets the relevant migrations for import from the provided migration template connection. + * Gets the migrations for import. + * + * Uses the migration template connection to ensure that only the relevant + * migrations are returned. * * @param array $migration_templates * Migration template. * * @return \Drupal\migrate\Entity\MigrationInterface[] + * The migrations for import. */ protected function getMigrations(array $migration_templates) { // Let the builder service create our migration configuration entities from @@ -143,13 +149,13 @@ trait MigrationCreationTrait { } /** - * Saves the relevant migrations for import from the provided template - * connection. + * Saves the migrations for import from the provided template connection. * * @param array $migration_templates * Migration template. * * @return array + * The migration IDs sorted in dependency order. */ protected function createMigrations(array $migration_templates) { $migration_ids = [];