You are here

public function MediaStorage::save in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/MediaStorage.php \Drupal\media\MediaStorage::save()
  2. 9 core/modules/media/src/MediaStorage.php \Drupal\media\MediaStorage::save()

Saves the entity permanently.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to save.

Return value

SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.

Overrides SqlContentEntityStorage::save

File

core/modules/media/src/MediaStorage.php, line 19

Class

MediaStorage
Defines the storage handler class for media.

Namespace

Drupal\media

Code

public function save(EntityInterface $media) {

  // For backwards compatibility, modules that override the Media entity
  // class, are not required to implement the prepareSave() method.
  // @todo For Drupal 8.7, consider throwing a deprecation notice if the
  //   method doesn't exist. See
  //   https://www.drupal.org/project/drupal/issues/2992426 for further
  //   discussion.
  if (method_exists($media, 'prepareSave')) {
    $media
      ->prepareSave();
  }
  return parent::save($media);
}