public function AcquiaContentHubSubscriberAuditCommands::audit in Acquia Content Hub 8.2
Audits imported entities and reimport if inconsistencies are found.
@option reimport Reimport inconsistent entities to Content Hub. @default reimport false
@option status The export status of the entities to audit, defaults to exported. Possible values: imported, queued. @default status imported
@command acquia:contenthub-audit-subscriber @aliases ach-audit-subscriber, ach-as
Parameters
string|null $entity_type_id: Entity type id.
Throws
\Exception
File
- modules/
acquia_contenthub_subscriber/ src/ Commands/ AcquiaContentHubSubscriberAuditCommands.php, line 67
Class
- AcquiaContentHubSubscriberAuditCommands
- Drush commands for Acquia Content Hub Subscriber Audit.
Namespace
Drupal\acquia_contenthub_subscriber\CommandsCode
public function audit(string $entity_type_id = '') {
$reimport = $this->input
->getOption('reimport');
if ($reimport) {
$warning_message = dt('Are you sure you want to republish entities to Content Hub?');
if ($this
->io()
->confirm($warning_message) == FALSE) {
throw new UserAbortException();
}
}
$status = strtolower($this->input
->getOption('status'));
$entities = $this
->getContentHubTrackedEntities($status, $entity_type_id);
$this
->output()
->writeln(dt('<fg=green>Auditing entities with export status = @status</>', [
'@status' => $status,
]));
// Setting up batch process.
$batch = [
'title' => dt('Checks @status entities and compares them with Content Hub.', [
'@status' => $status,
]),
'operations' => [],
'finished' => '\\Drupal\\acquia_contenthub\\AuditTrackEntities::batchFinished',
];
$chunks = array_chunk($entities, 50);
foreach ($chunks as $chunk) {
$batch['operations'][] = [
'\\Drupal\\acquia_contenthub\\AuditTrackEntities::batchProcess',
[
$chunk,
$reimport,
'subscriber_audit',
],
];
}
// Adds the batch sets.
batch_set($batch);
// Start the batch process.
drush_backend_batch_process();
}