You are here

public function DateRecurOccurrences::onEntityDelete in Recurring Dates Field 8.2

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

Respond to a entity deletion.

Parameters

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

File

src/DateRecurOccurrences.php, line 176

Class

DateRecurOccurrences
Manages occurrences tables and the data that populates them.

Namespace

Drupal\date_recur

Code

public function onEntityDelete(DateRecurValueEvent $event) : void {
  $list = $event
    ->getField();
  $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);
  $delete
    ->execute();
}