You are here

protected function MediaDevelGenerate::mediaKill in Media entity 8

Deletes all media of given media bundles.

Parameters

array $values: The input values from the settings form.

2 calls to MediaDevelGenerate::mediaKill()
MediaDevelGenerate::batchMediaKill in src/Plugin/DevelGenerate/MediaDevelGenerate.php
Batch version of mediaKill().
MediaDevelGenerate::generateMedia in src/Plugin/DevelGenerate/MediaDevelGenerate.php
Method for creating media when number of elements is less than 50.

File

src/Plugin/DevelGenerate/MediaDevelGenerate.php, line 377

Class

MediaDevelGenerate
Provides a MediaDevelGenerate plugin.

Namespace

Drupal\media_entity\Plugin\DevelGenerate

Code

protected function mediaKill($values) {
  $mids = $this->mediaStorage
    ->getQuery()
    ->condition('bundle', $values['media_bundles'], 'IN')
    ->execute();
  if (!empty($mids)) {
    $media = $this->mediaStorage
      ->loadMultiple($mids);
    $this->mediaStorage
      ->delete($media);
    $this
      ->setMessage($this
      ->t('Deleted %count media items.', [
      '%count' => count($mids),
    ]));
  }
}