function Media::postSave

Same name in other branches
  1. 8.9.x core/modules/media/src/Entity/Media.php \Drupal\media\Entity\Media::postSave()
  2. 10 core/modules/media/src/Entity/Media.php \Drupal\media\Entity\Media::postSave()
  3. 11.x core/modules/media/src/Entity/Media.php \Drupal\media\Entity\Media::postSave()

Overrides ContentEntityBase::postSave

File

core/modules/media/src/Entity/Media.php, line 365

Class

Media
Defines the media entity class.

Namespace

Drupal\media\Entity

Code

public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);
    $is_new = !$update;
    foreach ($this->translations as $langcode => $data) {
        if ($this->hasTranslation($langcode)) {
            $translation = $this->getTranslation($langcode);
            if ($translation->bundle->entity
                ->thumbnailDownloadsAreQueued() && $translation->shouldUpdateThumbnail($is_new)) {
                \Drupal::queue('media_entity_thumbnail')->createItem([
                    'id' => $translation->id(),
                ]);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.