public function AcquiaContentHubPublisherCommands::upgrade in Acquia Content Hub 8.2
Publisher Upgrade Command.
@command acquia:contenthub-publisher-upgrade @aliases ach-publisher-upgrade,ach-puup
File
- modules/
acquia_contenthub_publisher/ src/ Commands/ AcquiaContentHubPublisherCommands.php, line 90
Class
- AcquiaContentHubPublisherCommands
- Drush commands for Acquia Content Hub Publishers.
Namespace
Drupal\acquia_contenthub_publisher\CommandsCode
public function upgrade() {
// Only proceed if there still exists a legacy tracking table.
if (!$this->database
->schema()
->tableExists('acquia_contenthub_entities_tracking')) {
$this->logger
->log(LogLevel::CANCEL, dt('Legacy tracking table does not exist.'));
return;
}
// Make sure webhook stored is actually registered for this site in Plexus.
$settings = $this->clientFactory
->getSettings();
$client = $this->clientFactory
->getClient($settings);
if (!$client
->getSettings()
->getWebhook()) {
// Proceed to register a webhook in HMAC v2.
$webhook_url = Url::fromUri('internal:' . '/acquia-contenthub/webhook', [
'absolute' => TRUE,
])
->toString();
$webhook = $client
->getWebHook($webhook_url);
if (empty($webhook)) {
$connection_manager = \Drupal::service('acquia_contenthub.connection_manager');
$response = $connection_manager
->registerWebhook($webhook_url);
if (isset($response['success']) && FALSE === $response['success']) {
$message = dt('Registering webhooks encountered an error (code @code). @reason', [
'@code' => $response['error']['code'],
'@reason' => $response['error']['message'],
]);
$this->logger
->log(LogLevel::ERROR, $message);
return;
}
}
}
// Enqueue all exported entities.
$path = $this->moduleHandler
->getModule('acquia_contenthub_publisher')
->getPath();
$batch = [
'title' => t('Exporting'),
'operations' => [
[
'acquia_contenthub_publisher_enqueue_exported_entities',
[],
],
],
'finished' => 'acquia_contenthub_publisher_enqueue_exported_entities_finished',
'file' => $path . '/acquia_contenthub_publisher.migrate.inc',
];
batch_set($batch);
drush_backend_batch_process();
}