You are here

public function SaveMedia::execute in Media Entity Actions 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Action/SaveMedia.php \Drupal\media_entity_actions\Plugin\Action\SaveMedia::execute()

Executes the plugin.

Overrides ExecutableInterface::execute

File

src/Plugin/Action/SaveMedia.php, line 23

Class

SaveMedia
Saves a media item.

Namespace

Drupal\media_entity_actions\Plugin\Action

Code

public function execute(MediaInterface $entity = NULL) {
  if ($entity) {

    // We need to change at least one value, otherwise the changed timestamp
    // will not be updated.
    $entity
      ->setChangedTime(0)
      ->save();
  }
}