diff -u b/core/modules/migrate/src/Audit/AuditException.php b/core/modules/migrate/src/Audit/AuditException.php --- b/core/modules/migrate/src/Audit/AuditException.php +++ b/core/modules/migrate/src/Audit/AuditException.php @@ -4,7 +4,10 @@ use Drupal\migrate\Plugin\MigrationInterface; -class AuditException extends \Exception { +/** + * Exception thrown when a migration audit fails. + */ +class AuditException extends \RuntimeException { /** * AuditException constructor. @@ -12,7 +15,7 @@ * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration that caused the exception. * @param string $message - * The reason for the failure. + * The reason the audit failed. * @param \Exception $previous * (optional) The previous exception. */ diff -u b/core/modules/migrate/src/Audit/AuditorInterface.php b/core/modules/migrate/src/Audit/AuditorInterface.php --- b/core/modules/migrate/src/Audit/AuditorInterface.php +++ b/core/modules/migrate/src/Audit/AuditorInterface.php @@ -4,6 +4,14 @@ use Drupal\migrate\Plugin\MigrationInterface; +/** + * Defines an interface for migration auditors. + * + * A migration auditor is a class which can examine a migration to determine if + * it will cause conflicts with data already existing in the destination system. + * What kind of auditing it does, and how it does it, is up to the implementing + * class. + */ interface AuditorInterface { /** @@ -12,7 +20,12 @@ * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration to audit. * + * @throws \Drupal\migrate\Audit\AuditException if the audit fails. + * * @return array + * If the audit detects no potential conflicts, an empty array is returned. + * Otherwise, the return value will be an array with a single element: a + * string explaining the nature of the conflict, keyed by the migration ID. */ public function audit(MigrationInterface $migration); @@ -23,6 +36,8 @@ * The migrations to audit. * * @return array + * An array of potential conflict information, keyed by migration ID. See + * audit() for more information. */ public function auditMultiple(array $migrations); diff -u b/core/modules/migrate/src/Audit/IdAuditor.php b/core/modules/migrate/src/Audit/IdAuditor.php --- b/core/modules/migrate/src/Audit/IdAuditor.php +++ b/core/modules/migrate/src/Audit/IdAuditor.php @@ -2,10 +2,12 @@ namespace Drupal\migrate\Audit; -use Drupal\Component\Utility\NestedArray; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\migrate\Plugin\MigrationInterface; +/** + * Audits migrations that create content entities in the destination system. + */ class IdAuditor implements AuditorInterface { /** @@ -47,6 +49,16 @@ return $conflicts; } + /** + * Builds a conflict array. + * + * @param \Drupal\migrate\Plugin\MigrationInterface $migration + * The migration that has the conflict. + * + * @return array + * The conflict. See \Drupal\migrate\Audit\AuditorInterface::audit() for + * information on the format of the return value. + */ public static function conflict(MigrationInterface $migration) { $base_id = $migration->getBaseId(); diff -u b/core/modules/migrate/src/Audit/MaximumValueInterface.php b/core/modules/migrate/src/Audit/MaximumValueInterface.php --- b/core/modules/migrate/src/Audit/MaximumValueInterface.php +++ b/core/modules/migrate/src/Audit/MaximumValueInterface.php @@ -2,8 +2,25 @@ namespace Drupal\migrate\Audit; +/** + * Defines an interface for destination and ID maps which track a highest ID. + * + * When implemented by destination plugins, max() should return the highest ID + * of the destination entity type that exists in the system. So, for example, + * the entity:node plugin should return the highest node ID that exists, + * regardless of whether it was created by a migration. + * + * When implemented by an ID map, max() should return the highest migrated ID + * of the destination entity type. + */ interface MaximumValueInterface { + /** + * Returns the highest ID value tracked by the implementing plugin. + * + * @return int + * The highest ID. + */ public function max(); }