public function ContentHubConnectionManager::syncWebhookInterestListWithTrackingTables in Acquia Content Hub 8.2
Synchronizes this webhook's interest list with tracking table.
File
- src/
ContentHubConnectionManager.php, line 540
Class
- ContentHubConnectionManager
- Responsible for connection management actions.
Namespace
Drupal\acquia_contenthubCode
public function syncWebhookInterestListWithTrackingTables() {
$this
->initialize();
$database = \Drupal::database();
$module_handler = \Drupal::moduleHandler();
$config = $this
->getContentHubConfig();
$webhook_uuid = $config
->get("webhook.uuid");
$send_update = $config
->get('send_contenthub_updates') ?? TRUE;
// If subscriber.
if ($module_handler
->moduleExists('acquia_contenthub_subscriber')) {
$query = $database
->select('acquia_contenthub_subscriber_import_tracking', 't')
->fields('t', [
'entity_uuid',
]);
$query
->condition('status', 'imported');
$results = $query
->execute()
->fetchAll();
$uuids = [];
foreach ($results as $result) {
$uuids[] = $result->entity_uuid;
}
if (!empty($uuids) && $send_update) {
$this->client
->addEntitiesToInterestList($webhook_uuid, $uuids);
$this->logger
->notice('Added @count imported entities to interest list for webhook uuid = "@webhook_uuid".', [
'@count' => count($uuids),
'@webhook_uuid' => $webhook_uuid,
]);
}
}
// If publisher.
if ($module_handler
->moduleExists('acquia_contenthub_publisher')) {
$query = $database
->select('acquia_contenthub_publisher_export_tracking', 't')
->fields('t', [
'entity_uuid',
]);
$query
->condition('status', [
'imported',
'confirmed',
], 'IN');
$results = $query
->execute()
->fetchAll();
$uuids = [];
foreach ($results as $result) {
$uuids[] = $result->entity_uuid;
}
if (!empty($uuids) && $send_update) {
$this->client
->addEntitiesToInterestList($webhook_uuid, $uuids);
$this->logger
->notice('Added @count exported entities to interest list for webhook uuid = "@webhook_uuid".', [
'@count' => count($uuids),
'@webhook_uuid' => $webhook_uuid,
]);
}
}
}