You are here

public function LingotekContentMetadataFieldItemList::preSave in Lingotek Translation 8.2

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

Defines custom presave behavior for field values.

This method is called during the process of saving an entity, just before item values are written into storage.

Overrides FieldItemList::preSave

See also

\Drupal\Core\Field\FieldItemInterface::preSave()

File

src/Plugin/Field/LingotekContentMetadataFieldItemList.php, line 90

Class

LingotekContentMetadataFieldItemList
A computed field that provides a content entity's Lingotek metadata.

Namespace

Drupal\lingotek\Plugin\Field

Code

public function preSave() {

  /** @var \Drupal\lingotek\Entity\LingotekContentMetadata $metadata */
  $metadata = $this
    ->getContentMetadata();
  if ($metadata && !$metadata
    ->getContentEntityId()) {
    $metadata
      ->setEntity($this
      ->getEntity());
  }
  parent::preSave();
}