You are here

public function ContentHasherEventSubscriber::writeHash in Tome 8

Maintains a hash of imported content to support partial imports.

Parameters

\Drupal\tome_sync\Event\ContentCrudEvent $event: The content CRUD event.

File

modules/tome_sync/src/EventSubscriber/ContentHasherEventSubscriber.php, line 52

Class

ContentHasherEventSubscriber
Event subscriber that keeps the content hash table up to date.

Namespace

Drupal\tome_sync\EventSubscriber

Code

public function writeHash(ContentCrudEvent $event) {
  $entity = $event
    ->getContent();
  $content_name = TomeSyncHelper::getContentName($entity);
  $file_path = $this->contentStorage
    ->getFilePath($content_name);
  if (file_exists($file_path)) {
    $encoded_content = file_get_contents($file_path);
    $this->contentHasher
      ->writeHash($encoded_content, $content_name);
  }
}