You are here

public function UnpublishMedia::execute in Media Entity Actions 8

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

Executes the plugin.

Overrides ExecutableInterface::execute

File

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

Class

UnpublishMedia
Unpublishes a media item.

Namespace

Drupal\media_entity_actions\Plugin\Action

Code

public function execute(MediaInterface $entity = NULL) {
  if ($entity) {
    $entity
      ->setUnpublished()
      ->save();
  }
}