protected function SubscriberTracker::insertOrUpdate in Acquia Content Hub 8.2
Determines if an entity will be inserted or updated with a status.
Parameters
array $values: The array of values to insert.
string $status: The status of the tracking.
string $hash: The hash string.
Return value
\Drupal\Core\Database\StatementInterface|int|null Database statement.
Throws
\Exception
2 calls to SubscriberTracker::insertOrUpdate()
- SubscriberTracker::queue in modules/
acquia_contenthub_subscriber/ src/ SubscriberTracker.php - Add tracking for an entity in a self::QUEUED state.
- SubscriberTracker::track in modules/
acquia_contenthub_subscriber/ src/ SubscriberTracker.php - Add tracking for an entity in a self::EXPORTED state.
File
- modules/
acquia_contenthub_subscriber/ src/ SubscriberTracker.php, line 149
Class
- SubscriberTracker
- Subscriber Tracker database table methods.
Namespace
Drupal\acquia_contenthub_subscriberCode
protected function insertOrUpdate(array $values, $status, $hash = "") {
if (empty($values['entity_uuid'])) {
throw new \Exception("Cannot track a subscription without an entity uuid.");
}
$values['status'] = $status;
if ($hash) {
$values['hash'] = $hash;
}
$query = $this->database
->select(self::IMPORT_TRACKING_TABLE, 't')
->fields('t', [
'first_imported',
]);
$query
->condition('entity_uuid', $values['entity_uuid']);
$results = $query
->execute()
->fetchObject();
// If we've previously tracked this thing, set its created date.
if ($results) {
$query = $this->database
->update(self::IMPORT_TRACKING_TABLE)
->fields($values);
$query
->condition('entity_uuid', $values['entity_uuid']);
return $query
->execute();
}
$values['first_imported'] = date('c');
return $this->database
->insert(self::IMPORT_TRACKING_TABLE)
->fields($values)
->execute();
}