| Total Complexity | 5 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class BatchSeedJobHandler implements JobHandlerInterface |
||
| 17 | { |
||
| 18 | public const TYPE = "batch-seed-job"; |
||
| 19 | |||
| 20 | public function getType(): string |
||
| 21 | { |
||
| 22 | return self::TYPE; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function execute(JobHandlerConfigurationInterface $configuration, ExecutionEntity $execution, CommandContext $commandContext, ?string $tenantId): void |
||
| 26 | { |
||
| 27 | $batchId = $configuration->getBatchId(); |
||
| 28 | $batch = $commandContext->getBatchManager()->findBatchById($configuration->getBatchId()); |
||
| 29 | EnsureUtil::ensureNotNull("Batch with id '" . $this->batchId . "' cannot be found", "batch", $batch); |
||
| 30 | |||
| 31 | $batchJobHandler = $commandContext |
||
| 32 | ->getProcessEngineConfiguration() |
||
| 33 | ->getBatchHandlers() |
||
| 34 | ->get($batch->getType()); |
||
| 35 | |||
| 36 | $done = $batchJobHandler->createJobs($batch); |
||
| 37 | |||
| 38 | if (!$done) { |
||
| 39 | $batch->createSeedJob(); |
||
| 40 | } else { |
||
| 41 | // create monitor job initially without due date to |
||
| 42 | // enable rapid completion of simple batches |
||
| 43 | $batch->createMonitorJob(false); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | public function newConfiguration(string $canonicalString): JobHandlerConfigurationInterface |
||
| 50 | } |
||
| 51 | |||
| 52 | public function onDelete(JobHandlerConfigurationInterface $configuration, JobEntity $jobEntity): void |
||
| 54 | // do nothing |
||
| 55 | } |
||
| 56 | } |
||
| 57 |