public function DateRecurOccurrences::onEntityRevisionDelete in Recurring Dates Field 3.1.x
Same name and namespace in other branches
- 8.2 src/DateRecurOccurrences.php \Drupal\date_recur\DateRecurOccurrences::onEntityRevisionDelete()
- 3.x src/DateRecurOccurrences.php \Drupal\date_recur\DateRecurOccurrences::onEntityRevisionDelete()
- 3.0.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_recurCode
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();
}