function MediaDevelGenerate::batchCreateMediaItem
Same name in other branches
- 5.x devel_generate/src/Plugin/DevelGenerate/MediaDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\MediaDevelGenerate::batchCreateMediaItem()
Provides a batch version of createMediaItem().
Parameters
array $vars: The input values from the settings form.
iterable $context: Batch job context.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException Thrown if the storage handler couldn't be loaded.
\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if the entity type doesn't exist.
\Drupal\Core\Entity\EntityStorageException Thrown if the bundle does not exist or was needed but not specified.
See also
File
-
devel_generate/
src/ Plugin/ DevelGenerate/ MediaDevelGenerate.php, line 369
Class
- MediaDevelGenerate
- Provides a plugin that generates media entities.
Namespace
Drupal\devel_generate\Plugin\DevelGenerateCode
public function batchCreateMediaItem(array $vars, iterable &$context) {
if ($this->drushBatch) {
$this->createMediaItem($vars);
}
else {
$this->createMediaItem($context['results']);
}
if (!isset($context['results']['num'])) {
$context['results']['num'] = 0;
}
$context['results']['num']++;
}