function IdAuditor::audit

Same name in other branches
  1. 9 core/modules/migrate/src/Audit/IdAuditor.php \Drupal\migrate\Audit\IdAuditor::audit()
  2. 8.9.x core/modules/migrate/src/Audit/IdAuditor.php \Drupal\migrate\Audit\IdAuditor::audit()
  3. 10 core/modules/migrate/src/Audit/IdAuditor.php \Drupal\migrate\Audit\IdAuditor::audit()

Overrides AuditorInterface::audit

1 call to IdAuditor::audit()
IdAuditor::auditMultiple in core/modules/migrate/src/Audit/IdAuditor.php

File

core/modules/migrate/src/Audit/IdAuditor.php, line 21

Class

IdAuditor
Audits migrations that create content entities in the destination system.

Namespace

Drupal\migrate\Audit

Code

public function audit(MigrationInterface $migration) {
    // If the migration does not opt into auditing, it passes.
    if (!$migration->isAuditable()) {
        return AuditResult::pass($migration);
    }
    $interface = HighestIdInterface::class;
    $destination = $migration->getDestinationPlugin();
    if (!$destination instanceof HighestIdInterface) {
        throw new AuditException($migration, "Destination does not implement {$interface}");
    }
    $id_map = $migration->getIdMap();
    if (!$id_map instanceof HighestIdInterface) {
        throw new AuditException($migration, "ID map does not implement {$interface}");
    }
    if ($destination->getHighestId() > $id_map->getHighestId() || $destination instanceof EntityContentComplete && !$this->auditEntityComplete($migration)) {
        return AuditResult::fail($migration, [
            $this->t('The destination system contains data which was not created by a migration.'),
        ]);
    }
    return AuditResult::pass($migration);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.