public function LingotekEntity::setMetadataValue in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::setMetadataValue()
- 7.5 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
3 calls to LingotekEntity::setMetadataValue()
- 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
File
- lib/
Drupal/ lingotek/ LingotekEntity.php, line 204 - Defines LingotekEntity.
Class
- LingotekEntity
- A class wrapper for Lingotek-specific behavior on nodes.
Code
public function setMetadataValue($key, $value) {
$metadata = $this
->metadata();
if (!isset($metadata[$key])) {
db_insert('lingotek_entity_metadata')
->fields(array(
'entity_id' => $this
->getId(),
'entity_type' => $this
->getEntityType(),
'entity_key' => $key,
'value' => $value,
))
->execute();
}
else {
db_update('lingotek_entity_metadata')
->fields(array(
'value' => $value,
))
->condition('entity_id', $this
->getId())
->condition('entity_type', $this
->getEntityType())
->condition('entity_key', $key)
->execute();
}
}