You are here

public function Exporter::deleteContentExport in Tome 8

Deletes an exported content entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: An entity to delete.

Overrides ExporterInterface::deleteContentExport

File

modules/tome_sync/src/Exporter.php, line 156

Class

Exporter
Handles exporting of content and file entities.

Namespace

Drupal\tome_sync

Code

public function deleteContentExport(ContentEntityInterface $entity) {

  // It would be cool if hook_entity_translation_delete() is invoked for
  // every translation of an entity when it's deleted. But it isn't. :-(.
  foreach (array_keys($entity
    ->getTranslationLanguages()) as $langcode) {
    $this->contentStorage
      ->delete(TomeSyncHelper::getContentName($entity
      ->getTranslation($langcode)));
    $this
      ->unIndexContent($entity);
  }
  if ($entity instanceof FileInterface) {
    $this->fileSync
      ->deleteFileExport($entity);
  }
  $event = new ContentCrudEvent($entity);
  $this->eventDispatcher
    ->dispatch(TomeSyncEvents::DELETE_CONTENT, $event);
}