You are here

public function LanguageKeyValueItem::preSave in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  2. 8.2 src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  3. 4.0.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  4. 3.0.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  5. 3.1.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  6. 3.2.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  7. 3.3.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  8. 3.4.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  9. 3.5.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  10. 3.7.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()
  11. 3.8.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::preSave()

Defines custom presave behavior for field values.

This method is called during the process of saving an entity, just before values are written into storage. When storing a new entity, its identifier will not be available yet. This should be used to massage item property values or perform any other operation that needs to happen before values are stored. For instance this is the proper phase to auto-create a new entity for an entity reference field item, because this way it will be possible to store the referenced entity identifier.

Overrides FieldItemBase::preSave

File

src/Plugin/Field/FieldType/LanguageKeyValueItem.php, line 77

Class

LanguageKeyValueItem
Plugin implementation of the 'language_key_value' field type.

Namespace

Drupal\lingotek\Plugin\Field\FieldType

Code

public function preSave() {
  parent::preSave();
  if (is_object($this->values['language'])) {
    $this->values['language'] = $this->values['language']
      ->getId();
  }
}