public function ContentHubCommonActions::deleteRemoteEntity in Acquia Content Hub 8.2
Delete a remote entity if we own it.
Parameters
string $uuid: The uuid of the remote entity to delete.
Return value
bool|void Boolean for success or failure, void if nonexistent or not ours.
Throws
\Exception
File
- src/
ContentHubCommonActions.php, line 337
Class
- ContentHubCommonActions
- Common actions across the entirety of Content Hub.
Namespace
Drupal\acquia_contenthubCode
public function deleteRemoteEntity(string $uuid) {
if (!Uuid::isValid($uuid)) {
throw new \Exception(sprintf("Invalid uuid %s.", $uuid));
}
$event = new DeleteRemoteEntityEvent($uuid);
$this->dispatcher
->dispatch(AcquiaContentHubEvents::DELETE_REMOTE_ENTITY, $event);
$remote_entity = $this
->getRemoteEntity($uuid);
if (!$remote_entity) {
return;
//@codingStandardsIgnoreLine
}
$client = $this
->getClient();
$settings = $client
->getSettings();
if ($settings
->getUuid() !== $remote_entity
->getOrigin()) {
return;
//@codingStandardsIgnoreLine
}
$response = $client
->deleteEntity($uuid);
if ($response
->getStatusCode() !== 202) {
return FALSE;
}
$this->channel
->info(sprintf("Deleted entity with UUID = \"%s\" from Content Hub.", $uuid));
// Clean up the interest list.
$webhook_uuid = $settings
->getWebhook('uuid');
$send_update = $this->config
->get('send_contenthub_updates') ?? TRUE;
if ($send_update && Uuid::isValid($webhook_uuid)) {
$client
->deleteInterest($uuid, $webhook_uuid);
$this->channel
->info(sprintf("Deleted entity with UUID = \"%s\" from webhook's interest list.", $uuid));
}
return $response
->getStatusCode() === 202;
}