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\Console\Command;
6
use Illuminate\Queue\Failed\PrunableFailedJobProvider;
7
use Illuminate\Support\Carbon;
8
use Symfony\Component\Console\Attribute\AsCommand;
9
 
10
#[AsCommand(name: 'queue:prune-failed')]
11
class PruneFailedJobsCommand extends Command
12
{
13
    /**
14
     * The console command signature.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'queue:prune-failed
19
                {--hours=24 : The number of hours to retain failed jobs data}';
20
 
21
    /**
22
     * The name of the console command.
23
     *
24
     * This name is used to identify the command during lazy loading.
25
     *
26
     * @var string|null
27
     *
28
     * @deprecated
29
     */
30
    protected static $defaultName = 'queue:prune-failed';
31
 
32
    /**
33
     * The console command description.
34
     *
35
     * @var string
36
     */
37
    protected $description = 'Prune stale entries from the failed jobs table';
38
 
39
    /**
40
     * Execute the console command.
41
     *
42
     * @return int|null
43
     */
44
    public function handle()
45
    {
46
        $failer = $this->laravel['queue.failer'];
47
 
48
        if ($failer instanceof PrunableFailedJobProvider) {
49
            $count = $failer->prune(Carbon::now()->subHours($this->option('hours')));
50
        } else {
51
            $this->components->error('The ['.class_basename($failer).'] failed job storage driver does not support pruning.');
52
 
53
            return 1;
54
        }
55
 
56
        $this->components->info("{$count} entries deleted.");
57
    }
58
}