public function UpdatePublished::onHandleWebhook in Acquia Content Hub 8.2
On handle webhook event.
Parameters
\Drupal\acquia_contenthub\Event\HandleWebhookEvent $event: The handle webhook event.
File
- modules/
acquia_contenthub_publisher/ src/ EventSubscriber/ HandleWebhook/ UpdatePublished.php, line 49
Class
- UpdatePublished
- Class UpdatePublished.
Namespace
Drupal\acquia_contenthub_publisher\EventSubscriber\HandleWebhookCode
public function onHandleWebhook(HandleWebhookEvent $event) {
$payload = $event
->getPayload();
$client = $event
->getClient();
if ($payload['status'] == 'successful' && $payload['crud'] == 'update' && $payload['initiator'] == $client
->getSettings()
->getUuid()) {
$uuids = [];
if (isset($payload['assets']) && count($payload['assets'])) {
$types = [
'drupal8_content_entity',
'drupal8_config_entity',
];
foreach ($payload['assets'] as $asset) {
if (!in_array($asset['type'], $types)) {
continue;
}
$uuids[] = $asset['uuid'];
}
}
if ($uuids) {
$query = $this->database
->select('acquia_contenthub_publisher_export_tracking', 'acpet')
->fields('acpet', [
'entity_uuid',
]);
$query
->condition('acpet.entity_uuid', $uuids, 'IN');
$items = $query
->execute()
->fetchAll();
$uuids = [];
foreach ($items as $item) {
$uuids[] = $item->entity_uuid;
}
$update = $this->database
->update('acquia_contenthub_publisher_export_tracking')
->fields([
'status' => PublisherTracker::CONFIRMED,
]);
$update
->condition('entity_uuid', $uuids, 'IN');
$update
->execute();
}
}
}