You are here

public function SubscriberTracker::setStatusByUuid in Acquia Content Hub 8.2

Set the status of a particular item by its uuid.

Parameters

string $uuid: The uuid of an entity.

string $status: The status to set.

Throws

\Exception

1 call to SubscriberTracker::setStatusByUuid()
SubscriberTracker::setStatusByTypeId in modules/acquia_contenthub_subscriber/src/SubscriberTracker.php
Set the status of a particular item by its entity type and id.

File

modules/acquia_contenthub_subscriber/src/SubscriberTracker.php, line 270

Class

SubscriberTracker
Subscriber Tracker database table methods.

Namespace

Drupal\acquia_contenthub_subscriber

Code

public function setStatusByUuid(string $uuid, string $status) {
  $acceptable_statuses = [
    $this::AUTO_UPDATE_DISABLED,
    $this::IMPORTED,
    $this::QUEUED,
  ];
  if (!in_array($status, $acceptable_statuses)) {
    throw new \Exception(sprintf("The '%s' status is not valid. Please pass one of the following options: '%s'", $status, implode("', '", $acceptable_statuses)));
  }
  if (!$this
    ->isTracked($uuid)) {
    return;
  }
  $query = $this->database
    ->update(self::IMPORT_TRACKING_TABLE);
  $query
    ->fields([
    'status' => $status,
  ]);
  $query
    ->condition('entity_uuid', $uuid);
  $query
    ->execute();
}