diff --git a/src/Controller/MigrateController.php b/src/Controller/MigrateController.php index b0d13d2..296a245 100644 --- a/src/Controller/MigrateController.php +++ b/src/Controller/MigrateController.php @@ -9,12 +9,15 @@ namespace Drupal\migrate_upgrade\Controller; use Drupal\Core\Controller\ControllerBase; /** - * Controller methods for the migration. + * Provides controller methods for the migration. */ class MigrateController extends ControllerBase { /** * Sets a log filter and redirects to the log. + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + * A redirect response object that may be returned by the controller. */ public function showLog() { $_SESSION['dblog_overview_filter'] = []; diff --git a/src/Form/MigrateUpgradeForm.php b/src/Form/MigrateUpgradeForm.php index 88c7b37..a9ba852 100644 --- a/src/Form/MigrateUpgradeForm.php +++ b/src/Form/MigrateUpgradeForm.php @@ -17,24 +17,30 @@ use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate_upgrade\MigrationCreationTrait; /** - * Multi-step form for performing direct site upgrades. + * Defines a multi-step form for performing direct site upgrades. */ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { use MigrationCreationTrait; /** - * The choices of what to do when an upgrade has previously been run. + * If a migration has previously run, perform an incremental migration. */ const MIGRATE_UPGRADE_INCREMENTAL = 1; + + /** + * If a migration has previously run, roll it back and start fresh. + */ const MIGRATE_UPGRADE_ROLLBACK = 2; /** + * 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 * - * @var array + * @var array[] */ protected $moduleUpgradePaths = [ 'd6_action_settings' => [ @@ -619,7 +625,7 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { public function submitForm(array &$form, FormStateInterface $form_state) {} /** - * Build the form presenting an overview of the migration process. + * Builds the form presenting an overview of the migration process. * * @param array $form * An associative array containing the structure of the form. @@ -692,7 +698,7 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { } /** - * Overview form submission handler. + * Form submission handler for the overview form. * * @param array $form * An associative array containing the structure of the form. @@ -715,8 +721,9 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { } /** - * Build the form gathering database credential and file location information. - * This is largely borrowed from SiteSettingsForm. + * Builds the database credential form and adds file location information. + * + * This is largely borrowed from \Drupal\Core\Installer\Form\SiteSettingsForm. * * @param array $form * An associative array containing the structure of the form. @@ -754,7 +761,7 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { $form['database']['driver']['#disabled'] = TRUE; } - // Add driver specific configuration options. + // Add driver-specific configuration options. foreach ($drivers as $key => $driver) { $form['database']['driver']['#options'][$key] = $driver->name(); @@ -815,7 +822,7 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { } /** - * Credential form validation handler. + * Validation handler for the credentials form. * * @param array $form * An associative array containing the structure of the form. @@ -896,7 +903,7 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { } /** - * Credential form submission handler. + * Submission handler for the credentials form. * * @param array $form * An associative array containing the structure of the form. @@ -910,7 +917,7 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { } /** - * Build the form gathering database credential and file location information. + * Confirmation form for rollbacks, missing migrations, etc. * * @param array $form * An associative array containing the structure of the form. @@ -1041,7 +1048,7 @@ class MigrateUpgradeForm extends FormBase implements ConfirmFormInterface { } /** - * Credential form submission handler. + * Submission handler for the confirmation form. * * @param array $form * An associative array containing the structure of the form. diff --git a/src/MigrateMessageCapture.php b/src/MigrateMessageCapture.php index 9f622f6..3ccef90 100644 --- a/src/MigrateMessageCapture.php +++ b/src/MigrateMessageCapture.php @@ -10,8 +10,7 @@ namespace Drupal\migrate_upgrade; use Drupal\migrate\MigrateMessageInterface; /** - * Defines a migrate message class for capturing messages rather than - * displaying them directly. + * Allows capturing messages rather than displaying them directly. */ class MigrateMessageCapture implements MigrateMessageInterface { @@ -30,14 +29,14 @@ class MigrateMessageCapture implements MigrateMessageInterface { } /** - * Clear out any captured messages. + * Clears out any captured messages. */ public function clear() { $this->messages = []; } /** - * Return any captured messages. + * Returns any captured messages. * * @return array */ diff --git a/src/MigrateUpgradeRunBatch.php b/src/MigrateUpgradeRunBatch.php index 3df43da..667f3b8 100644 --- a/src/MigrateUpgradeRunBatch.php +++ b/src/MigrateUpgradeRunBatch.php @@ -54,13 +54,13 @@ class MigrateUpgradeRunBatch { protected static $messages; /** - * Run a single migration batch. + * Runs a single migration batch. * - * @param array $initial_ids + * @param int[] $initial_ids * The full set of migration IDs to import. * @param string $operation * 'import' or 'rollback'. - * @param $context + * @param array $context * The batch context. */ public static function run($initial_ids, $operation, &$context) { @@ -224,7 +224,7 @@ class MigrateUpgradeRunBatch { } /** - * A helper method to grab the logger using the migrate_upgrade channel. + * Returns the logger using the migrate_upgrade channel. * * @return \Psr\Log\LoggerInterface * The logger instance. @@ -234,16 +234,16 @@ class MigrateUpgradeRunBatch { } /** - * Implementation of the Batch API finished method. + * Implements the Batch API finished method. */ public static function finished($success, $results, $operations, $elapsed) { static::displayResults($results); } /** - * Display counts of success/failures on the migration upgrade complete page. + * Displays counts of success/failures on the migration upgrade complete page. * - * @param $results + * @param array $results * An array of result data built during the batch. */ protected static function displayResults($results) { @@ -290,7 +290,7 @@ class MigrateUpgradeRunBatch { } /** - * React to item import. + * Reacts to item import. * * @param \Drupal\migrate\Event\MigratePostRowSaveEvent $event * The post-save event. @@ -303,7 +303,7 @@ class MigrateUpgradeRunBatch { } /** - * React to item deletion. + * Reacts to item deletion. * * @param \Drupal\migrate\Event\MigrateRowDeleteEvent $event * The post-save event. @@ -316,7 +316,7 @@ class MigrateUpgradeRunBatch { } /** - * Count up any map save events. + * Counts up any map save events. * * @param \Drupal\migrate\Event\MigrateMapSaveEvent $event * The map event. @@ -326,7 +326,7 @@ class MigrateUpgradeRunBatch { } /** - * Count up any map delete events. + * Counts up any map delete events. * * @param \Drupal\migrate\Event\MigrateMapDeleteEvent $event * The map event. @@ -336,7 +336,7 @@ class MigrateUpgradeRunBatch { } /** - * Display any messages being logged to the ID map. + * Displays any messages being logged to the ID map. * * @param \Drupal\migrate\Event\MigrateIdMapMessageEvent $event * The message event. diff --git a/src/MigrationCreationTrait.php b/src/MigrationCreationTrait.php index e808dfd..6e6070a 100644 --- a/src/MigrationCreationTrait.php +++ b/src/MigrationCreationTrait.php @@ -15,22 +15,23 @@ use Drupal\migrate\Plugin\RequirementsInterface; use Drupal\Component\Plugin\Exception\PluginNotFoundException; /** - * Trait providing functionality to create the appropriate migrations for - * a given source Drupal database. Note the class using the trait must - * implement TranslationInterface (i.e., define t()). + * Creates the appropriate migrations for a given source Drupal database. + * + * Note the class using the trait must implement + * \Drupal\Core\StringTranslation\TranslationInterface (i.e., define t()). */ trait MigrationCreationTrait { /** - * Set up the relevant migrations for import from the provided database - * connection. + * Sets up the relevant migrations for import from a database connection. * * @param \Drupal\Core\Database\Database $database * Database array representing the source Drupal database. * @param string $source_base_path * Address of the source Drupal site (e.g., http://example.com/). * - * @return array + * @return int[] + * An array of Migration entity IDs. */ protected function createMigrations(array $database, $source_base_path) { // Set up the connection. @@ -94,11 +95,14 @@ trait MigrationCreationTrait { } /** - * Determine what version of Drupal the source database contains. + * Determines what version of Drupal the source database contains. * * @param \Drupal\Core\Database\Connection $connection + * The database connection object. * * @return int|FALSE + * An integer representing the major branch of Drupal core (e.g. '6' for + * Drupal 6.x), or FALSE if no valid version is matched. */ protected function getLegacyDrupalVersion(Connection $connection) { // Don't assume because a table of that name exists, that it has the columns