-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathBatch.php
More file actions
32 lines (26 loc) · 972 Bytes
/
Batch.php
File metadata and controls
32 lines (26 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
declare(strict_types=1);
namespace DrupalCodeGenerator\Command;
use DrupalCodeGenerator\Application;
use DrupalCodeGenerator\Asset\AssetCollection;
use DrupalCodeGenerator\Attribute\Generator;
use DrupalCodeGenerator\GeneratorType;
#[Generator(
name: 'batch',
description: 'Generates a batch',
templatePath: Application::TEMPLATE_PATH . '/_batch',
type: GeneratorType::MODULE_COMPONENT
)]
final class Batch extends BaseGenerator {
/**
* {@inheritDoc}
*/
protected function generate(array &$vars, AssetCollection $assets): void {
$ir = $this->createInterviewer($vars);
$vars['machine_name'] = $ir->askMachineName();
$vars['class'] = $ir->askClass(default: '{machine_name|camelize}Batch');
$vars['operation_callback'] = $ir->ask('Operation callback method name', 'processItem');
$vars['finished_callback'] = $ir->ask('Finished callback method name', 'finished');
$assets->addFile('src/{class}.php', 'batch.twig');
}
}