private function MediaDevelGenerate::generateMedia in Media entity 8
Method for creating media when number of elements is less than 50.
Parameters
array $values: Array of values submitted through a form.
1 call to MediaDevelGenerate::generateMedia()
- MediaDevelGenerate::generateElements in src/
Plugin/ DevelGenerate/ MediaDevelGenerate.php
File
- src/
Plugin/ DevelGenerate/ MediaDevelGenerate.php, line 242
Class
- MediaDevelGenerate
- Provides a MediaDevelGenerate plugin.
Namespace
Drupal\media_entity\Plugin\DevelGenerateCode
private function generateMedia($values) {
$values['media_bundles'] = array_filter($values['media_bundles']);
if (!empty($values['kill']) && $values['media_bundles']) {
$this
->mediaKill($values);
}
if (!empty($values['media_bundles'])) {
// Generate media.
$this
->preGenerate($values);
$start = time();
for ($i = 1; $i <= $values['num']; $i++) {
$this
->createMediaItem($values);
if (function_exists('drush_log') && $i % drush_get_option('feedback', 1000) == 0) {
$now = time();
drush_log(dt('Completed !feedback media items (!rate media/min)', [
'!feedback' => drush_get_option('feedback', 1000),
'!rate' => drush_get_option('feedback', 1000) * 60 / ($now - $start),
]), 'ok');
$start = $now;
}
}
}
$this
->setMessage($this
->formatPlural($values['num'], '1 media created.', 'Finished creating @count media items.'));
}