3 namespace Drupal\media;
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
9 * Defines the storage handler class for media.
11 * The default storage is overridden to handle metadata fetching outside of the
12 * database transaction.
14 class MediaStorage extends SqlContentEntityStorage {
19 public function save(EntityInterface $media) {
20 // For backwards compatibility, modules that override the Media entity
21 // class, are not required to implement the prepareSave() method.
22 // @todo For Drupal 8.7, consider throwing a deprecation notice if the
23 // method doesn't exist. See
24 // https://www.drupal.org/project/drupal/issues/2992426 for further
26 if (method_exists($media, 'prepareSave')) {
27 $media->prepareSave();
29 return parent::save($media);