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\Console\Scheduling;
4
 
5
use Illuminate\Console\Command;
6
use Illuminate\Console\Events\ScheduledBackgroundTaskFinished;
7
use Illuminate\Contracts\Events\Dispatcher;
8
use Symfony\Component\Console\Attribute\AsCommand;
9
 
10
#[AsCommand(name: 'schedule:finish')]
11
class ScheduleFinishCommand extends Command
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'schedule:finish {id} {code=0}';
19
 
20
    /**
21
     * The name of the console command.
22
     *
23
     * This name is used to identify the command during lazy loading.
24
     *
25
     * @var string|null
26
     *
27
     * @deprecated
28
     */
29
    protected static $defaultName = 'schedule:finish';
30
 
31
    /**
32
     * The console command description.
33
     *
34
     * @var string
35
     */
36
    protected $description = 'Handle the completion of a scheduled command';
37
 
38
    /**
39
     * Indicates whether the command should be shown in the Artisan command list.
40
     *
41
     * @var bool
42
     */
43
    protected $hidden = true;
44
 
45
    /**
46
     * Execute the console command.
47
     *
48
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
49
     * @return void
50
     */
51
    public function handle(Schedule $schedule)
52
    {
53
        collect($schedule->events())->filter(function ($value) {
54
            return $value->mutexName() == $this->argument('id');
55
        })->each(function ($event) {
56
            $event->finish($this->laravel, $this->argument('code'));
57
 
58
            $this->laravel->make(Dispatcher::class)->dispatch(new ScheduledBackgroundTaskFinished($event));
59
        });
60
    }
61
}