You are here

public function DateRecurOccurrences::onEntityRevisionDelete in Recurring Dates Field 3.0.x

Same name and namespace in other branches
  1. 8.2 src/DateRecurOccurrences.php \Drupal\date_recur\DateRecurOccurrences::onEntityRevisionDelete()
  2. 3.x src/DateRecurOccurrences.php \Drupal\date_recur\DateRecurOccurrences::onEntityRevisionDelete()
  3. 3.1.x src/DateRecurOccurrences.php \Drupal\date_recur\DateRecurOccurrences::onEntityRevisionDelete()

Respond to a entity revision deletion.

Parameters

\Drupal\date_recur\Event\DateRecurValueEvent $event: The date recur event.

File

src/DateRecurOccurrences.php, line 194

Class

DateRecurOccurrences
Manages occurrences tables and the data that populates them.

Namespace

Drupal\date_recur

Code

public function onEntityRevisionDelete(DateRecurValueEvent $event) : void {
  $list = $event
    ->getField();
  $entity = $list
    ->getEntity();
  $fieldDefinition = $list
    ->getFieldDefinition();
  $tableName = static::getOccurrenceCacheStorageTableName($fieldDefinition
    ->getFieldStorageDefinition());
  $delete = $this->database
    ->delete($tableName);

  /** @var string|int $entityId */
  $entityId = $list
    ->getEntity()
    ->id();
  $delete
    ->condition('entity_id', (string) $entityId);
  if ($entity
    ->getEntityType()
    ->isRevisionable() && $entity instanceof RevisionableInterface) {
    $delete
      ->condition('revision_id', $entity
      ->getRevisionId());
  }
  $delete
    ->execute();
}