You are here

protected function MediaDevelGenerate::mediaKill in Devel 4.x

Same name and namespace in other branches
  1. 8.3 devel_generate/src/Plugin/DevelGenerate/MediaDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\MediaDevelGenerate::mediaKill()

Deletes all media of given media media types.

Parameters

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

Throws

\Drupal\Core\Entity\EntityStorageException Thrown if the media type does not exist.

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

File

devel_generate/src/Plugin/DevelGenerate/MediaDevelGenerate.php, line 444

Class

MediaDevelGenerate
Provides a plugin that generates media entities.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

protected function mediaKill(array $values) {
  $mids = $this->mediaStorage
    ->getQuery()
    ->condition('bundle', $values['media_types'], '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),
    ]));
  }
}