function Media::preSave

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

Overrides ContentEntityBase::preSave

File

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

Class

Media
Defines the media entity class.

Namespace

Drupal\media\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    if (!$this->getOwner()) {
        $this->setOwnerId(0);
    }
    // If no thumbnail has been explicitly set, use the default thumbnail.
    if ($this->get('thumbnail')
        ->isEmpty()) {
        $this->thumbnail->target_id = $this->loadThumbnail()
            ->id();
    }
}

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