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\Foundation\Console;
4
 
5
use Illuminate\Console\Concerns\CreatesMatchingTest;
6
use Illuminate\Console\GeneratorCommand;
7
use Symfony\Component\Console\Attribute\AsCommand;
8
use Symfony\Component\Console\Input\InputOption;
9
 
10
#[AsCommand(name: 'make:job')]
11
class JobMakeCommand extends GeneratorCommand
12
{
13
    use CreatesMatchingTest;
14
 
15
    /**
16
     * The console command name.
17
     *
18
     * @var string
19
     */
20
    protected $name = 'make:job';
21
 
22
    /**
23
     * The name of the console command.
24
     *
25
     * This name is used to identify the command during lazy loading.
26
     *
27
     * @var string|null
28
     *
29
     * @deprecated
30
     */
31
    protected static $defaultName = 'make:job';
32
 
33
    /**
34
     * The console command description.
35
     *
36
     * @var string
37
     */
38
    protected $description = 'Create a new job class';
39
 
40
    /**
41
     * The type of class being generated.
42
     *
43
     * @var string
44
     */
45
    protected $type = 'Job';
46
 
47
    /**
48
     * Get the stub file for the generator.
49
     *
50
     * @return string
51
     */
52
    protected function getStub()
53
    {
54
        return $this->option('sync')
55
                        ? $this->resolveStubPath('/stubs/job.stub')
56
                        : $this->resolveStubPath('/stubs/job.queued.stub');
57
    }
58
 
59
    /**
60
     * Resolve the fully-qualified path to the stub.
61
     *
62
     * @param  string  $stub
63
     * @return string
64
     */
65
    protected function resolveStubPath($stub)
66
    {
67
        return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
68
                        ? $customPath
69
                        : __DIR__.$stub;
70
    }
71
 
72
    /**
73
     * Get the default namespace for the class.
74
     *
75
     * @param  string  $rootNamespace
76
     * @return string
77
     */
78
    protected function getDefaultNamespace($rootNamespace)
79
    {
80
        return $rootNamespace.'\Jobs';
81
    }
82
 
83
    /**
84
     * Get the console command options.
85
     *
86
     * @return array
87
     */
88
    protected function getOptions()
89
    {
90
        return [
91
            ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the job already exists'],
92
            ['sync', null, InputOption::VALUE_NONE, 'Indicates that job should be synchronous'],
93
        ];
94
    }
95
}