3 namespace Drupal\media_entity_actions\Plugin\Action;
5 use Drupal\Core\Action\ActionBase;
6 use Drupal\Core\Session\AccountInterface;
7 use Drupal\media\MediaInterface;
13 * id = "media_save_action",
14 * label = @Translation("Save media"),
18 class SaveMedia extends ActionBase {
23 public function execute(MediaInterface $entity = NULL) {
25 // We need to change at least one value, otherwise the changed timestamp
26 // will not be updated.
27 $entity->setChangedTime(0)->save();
34 public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
35 /** @var \Drupal\media\MediaInterface $object */
36 return $object->access('update', $account, $return_as_object);