Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Queue\Console;
4
 
5
use Illuminate\Bus\BatchRepository;
6
use Illuminate\Console\Command;
7
use Symfony\Component\Console\Attribute\AsCommand;
8
 
9
#[AsCommand(name: 'queue:retry-batch')]
10
class RetryBatchCommand extends Command
11
{
12
    /**
13
     * The console command signature.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'queue:retry-batch {id : The ID of the batch whose failed jobs should be retried}';
18
 
19
    /**
20
     * The name of the console command.
21
     *
22
     * This name is used to identify the command during lazy loading.
23
     *
24
     * @var string|null
25
     *
26
     * @deprecated
27
     */
28
    protected static $defaultName = 'queue:retry-batch';
29
 
30
    /**
31
     * The console command description.
32
     *
33
     * @var string
34
     */
35
    protected $description = 'Retry the failed jobs for a batch';
36
 
37
    /**
38
     * Execute the console command.
39
     *
40
     * @return int|null
41
     */
42
    public function handle()
43
    {
44
        $batch = $this->laravel[BatchRepository::class]->find($id = $this->argument('id'));
45
 
46
        if (! $batch) {
47
            $this->components->error("Unable to find a batch with ID [{$id}].");
48
 
49
            return 1;
50
        } elseif (empty($batch->failedJobIds)) {
51
            $this->components->error('The given batch does not contain any failed jobs.');
52
 
53
            return 1;
54
        }
55
 
56
        $this->components->info("Pushing failed queue jobs of the batch [$id] back onto the queue.");
57
 
58
        foreach ($batch->failedJobIds as $failedJobId) {
59
            $this->components->task($failedJobId, fn () => $this->callSilent('queue:retry', ['id' => $failedJobId]) == 0);
60
        }
61
 
62
        $this->newLine();
63
    }
64
}