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\InputArgument;
9
use Symfony\Component\Console\Input\InputOption;
10
 
11
#[AsCommand(name: 'make:command')]
12
class ConsoleMakeCommand extends GeneratorCommand
13
{
14
    use CreatesMatchingTest;
15
 
16
    /**
17
     * The console command name.
18
     *
19
     * @var string
20
     */
21
    protected $name = 'make:command';
22
 
23
    /**
24
     * The name of the console command.
25
     *
26
     * This name is used to identify the command during lazy loading.
27
     *
28
     * @var string|null
29
     *
30
     * @deprecated
31
     */
32
    protected static $defaultName = 'make:command';
33
 
34
    /**
35
     * The console command description.
36
     *
37
     * @var string
38
     */
39
    protected $description = 'Create a new Artisan command';
40
 
41
    /**
42
     * The type of class being generated.
43
     *
44
     * @var string
45
     */
46
    protected $type = 'Console command';
47
 
48
    /**
49
     * Replace the class name for the given stub.
50
     *
51
     * @param  string  $stub
52
     * @param  string  $name
53
     * @return string
54
     */
55
    protected function replaceClass($stub, $name)
56
    {
57
        $stub = parent::replaceClass($stub, $name);
58
 
59
        return str_replace(['dummy:command', '{{ command }}'], $this->option('command'), $stub);
60
    }
61
 
62
    /**
63
     * Get the stub file for the generator.
64
     *
65
     * @return string
66
     */
67
    protected function getStub()
68
    {
69
        $relativePath = '/stubs/console.stub';
70
 
71
        return file_exists($customPath = $this->laravel->basePath(trim($relativePath, '/')))
72
            ? $customPath
73
            : __DIR__.$relativePath;
74
    }
75
 
76
    /**
77
     * Get the default namespace for the class.
78
     *
79
     * @param  string  $rootNamespace
80
     * @return string
81
     */
82
    protected function getDefaultNamespace($rootNamespace)
83
    {
84
        return $rootNamespace.'\Console\Commands';
85
    }
86
 
87
    /**
88
     * Get the console command arguments.
89
     *
90
     * @return array
91
     */
92
    protected function getArguments()
93
    {
94
        return [
95
            ['name', InputArgument::REQUIRED, 'The name of the command'],
96
        ];
97
    }
98
 
99
    /**
100
     * Get the console command options.
101
     *
102
     * @return array
103
     */
104
    protected function getOptions()
105
    {
106
        return [
107
            ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the console command already exists'],
108
            ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned', 'command:name'],
109
        ];
110
    }
111
}