You are here

public function LingotekConfigChunk::setMetadataValue in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.3 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::setMetadataValue()
  2. 7.4 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::setMetadataValue()

Sets a Lingotek metadata value for this item.

Parameters

string $key: The key for a name/value pair.

string $value: The value for a name/value pair.

Overrides LingotekTranslatableEntity::setMetadataValue

5 calls to LingotekConfigChunk::setMetadataValue()
LingotekConfigChunk::setDocumentId in lib/Drupal/lingotek/LingotekConfigChunk.php
Set the chunk's document ID in the config metadata table
LingotekConfigChunk::setLastError in lib/Drupal/lingotek/LingotekConfigChunk.php
Set the chunk's last error in the config metadata table
LingotekConfigChunk::setProjectId in lib/Drupal/lingotek/LingotekConfigChunk.php
Set the chunk's project ID in the config metadata table
LingotekConfigChunk::setStatus in lib/Drupal/lingotek/LingotekConfigChunk.php
Set the chunk's status in the config metadata table
LingotekConfigChunk::setTargetsStatus in lib/Drupal/lingotek/LingotekConfigChunk.php
Set the chunk's target status(es) in the config metadata table

File

lib/Drupal/lingotek/LingotekConfigChunk.php, line 638
Defines LingotekConfigChunk.

Class

LingotekConfigChunk
A class wrapper for Lingotek-specific behavior on ConfigChunks.

Code

public function setMetadataValue($key, $value) {
  $metadata = $this
    ->metadata();
  $timestamp = time();
  if (!isset($metadata[$key])) {
    db_insert('{lingotek_config_metadata}')
      ->fields(array(
      'id' => $this->cid,
      'config_key' => $key,
      'value' => $value,
      'created' => $timestamp,
      'modified' => $timestamp,
    ))
      ->execute();
  }
  else {
    db_update('{lingotek_config_metadata}')
      ->fields(array(
      'value' => $value,
      'modified' => $timestamp,
    ))
      ->condition('id', $this->cid)
      ->condition('config_key', $key)
      ->execute();
  }
}