You are here

public function ContentHasher::writeHash in Tome 8

Writes a content hash.

Parameters

string $encoded_content: The encoded content, typically JSON.

string $content_name: The content name.

Overrides ContentHasherInterface::writeHash

File

modules/tome_sync/src/ContentHasher.php, line 43

Class

ContentHasher
Hashes normalized content in the database.

Namespace

Drupal\tome_sync

Code

public function writeHash($encoded_content, $content_name) {
  $hash = sha1($encoded_content);
  $this->database
    ->upsert('tome_sync_content_hash')
    ->key('name')
    ->fields([
    'name' => $content_name,
    'hash' => $hash,
  ])
    ->execute();
}