public function LingotekComment::setMetadataValue in Lingotek Translation 7.3
Same name and namespace in other branches
- 7.2 lib/Drupal/lingotek/LingotekComment.php \LingotekComment::setMetadataValue()
- 7.4 lib/Drupal/lingotek/LingotekComment.php \LingotekComment::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
File
- lib/
Drupal/ lingotek/ LingotekComment.php, line 312 - Defines LingotekComment.
Class
- LingotekComment
- A class wrapper for Lingotek-specific behavior on Comments.
Code
public function setMetadataValue($key, $value) {
$metadata = $this
->metadata();
if (!isset($metadata[$key])) {
db_insert('lingotek_entity_metadata')
->fields(array(
'entity_id' => $this->comment->cid,
'entity_type' => self::DRUPAL_ENTITY_TYPE,
'entity_key' => $key,
'value' => $value,
))
->execute();
}
else {
db_update('lingotek_entity_metadata')
->fields(array(
'value' => $value,
))
->condition('entity_id', $this->comment->cid)
->condition('entity_type', self::DRUPAL_ENTITY_TYPE)
->condition('entity_key', $key)
->execute();
}
}