You are here

public function Exporter::exportContent in Tome 8

Exports a content entity to the target storage.

Parameters

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

Overrides ExporterInterface::exportContent

File

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

Class

Exporter
Handles exporting of content and file entities.

Namespace

Drupal\tome_sync

Code

public function exportContent(ContentEntityInterface $entity) {
  if (in_array($entity
    ->getEntityTypeId(), static::$excludedTypes, TRUE)) {
    return;
  }
  $this
    ->switchToAdmin();
  $data = $this->serializer
    ->normalize($entity, 'json');
  $this->contentStorage
    ->write(TomeSyncHelper::getContentName($entity), $data);
  $this
    ->indexContent($entity);
  if ($entity instanceof FileInterface) {
    $this->fileSync
      ->exportFile($entity);
  }
  $event = new ContentCrudEvent($entity);
  $this->eventDispatcher
    ->dispatch(TomeSyncEvents::EXPORT_CONTENT, $event);
  $this
    ->switchBack();
}