You are here

public function LingotekEntity::setMetadataValue in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.5 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::setMetadataValue()
  2. 7.6 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::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

4 calls to LingotekEntity::setMetadataValue()
LingotekEntity::setExclusiveTargetsStatus in lib/Drupal/lingotek/LingotekEntity.php
LingotekEntity::setLastError in lib/Drupal/lingotek/LingotekEntity.php
Set the entity's last error in the entity metadata table
LingotekEntity::setStatus in lib/Drupal/lingotek/LingotekEntity.php
LingotekEntity::setTargetsStatus in lib/Drupal/lingotek/LingotekEntity.php
Assign the entity's target status(es) in the config metadata table

File

lib/Drupal/lingotek/LingotekEntity.php, line 211
Defines LingotekEntity.

Class

LingotekEntity
A class wrapper for Lingotek-specific behavior on nodes.

Code

public function setMetadataValue($key, $value) {
  $metadata = $this
    ->metadata();
  $entity_type = $this
    ->getEntityType();
  $entity_id = $this
    ->getNodeId();
  if (!isset($metadata[$key])) {
    db_insert('lingotek_entity_metadata')
      ->fields(array(
      'entity_id' => $entity_id,
      'entity_type' => $entity_type,
      'entity_key' => $key,
      'value' => $value,
    ))
      ->execute();
  }
  else {
    db_update('lingotek_entity_metadata')
      ->fields(array(
      'value' => $value,
    ))
      ->condition('entity_id', $entity_id)
      ->condition('entity_type', $entity_type)
      ->condition('entity_key', $key)
      ->execute();
  }
  lingotek_cache_clear($entity_type, $entity_id);
}