class MediaStorage

Same name and namespace in other branches
  1. 10 core/modules/media/src/MediaStorage.php \Drupal\media\MediaStorage
  2. 11.x core/modules/media/src/MediaStorage.php \Drupal\media\MediaStorage
  3. 8.9.x core/modules/media/src/MediaStorage.php \Drupal\media\MediaStorage

Defines the storage handler class for media.

The default storage is overridden to handle metadata fetching outside of the database transaction.

Hierarchy

Expanded class hierarchy of MediaStorage

File

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

Namespace

Drupal\media
View source
class MediaStorage extends SqlContentEntityStorage {
  
  /**
   * {@inheritdoc}
   */
  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);
  }

}

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