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\GeneratorCommand;
6
use Symfony\Component\Console\Attribute\AsCommand;
7
use Symfony\Component\Console\Input\InputOption;
8
 
9
#[AsCommand(name: 'make:exception')]
10
class ExceptionMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'make:exception';
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 = 'make:exception';
29
 
30
    /**
31
     * The console command description.
32
     *
33
     * @var string
34
     */
35
    protected $description = 'Create a new custom exception class';
36
 
37
    /**
38
     * The type of class being generated.
39
     *
40
     * @var string
41
     */
42
    protected $type = 'Exception';
43
 
44
    /**
45
     * Get the stub file for the generator.
46
     *
47
     * @return string
48
     */
49
    protected function getStub()
50
    {
51
        if ($this->option('render')) {
52
            return $this->option('report')
53
                ? __DIR__.'/stubs/exception-render-report.stub'
54
                : __DIR__.'/stubs/exception-render.stub';
55
        }
56
 
57
        return $this->option('report')
58
            ? __DIR__.'/stubs/exception-report.stub'
59
            : __DIR__.'/stubs/exception.stub';
60
    }
61
 
62
    /**
63
     * Determine if the class already exists.
64
     *
65
     * @param  string  $rawName
66
     * @return bool
67
     */
68
    protected function alreadyExists($rawName)
69
    {
70
        return class_exists($this->rootNamespace().'Exceptions\\'.$rawName);
71
    }
72
 
73
    /**
74
     * Get the default namespace for the class.
75
     *
76
     * @param  string  $rootNamespace
77
     * @return string
78
     */
79
    protected function getDefaultNamespace($rootNamespace)
80
    {
81
        return $rootNamespace.'\Exceptions';
82
    }
83
 
84
    /**
85
     * Get the console command options.
86
     *
87
     * @return array
88
     */
89
    protected function getOptions()
90
    {
91
        return [
92
            ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the exception already exists'],
93
            ['render', null, InputOption::VALUE_NONE, 'Create the exception with an empty render method'],
94
            ['report', null, InputOption::VALUE_NONE, 'Create the exception with an empty report method'],
95
        ];
96
    }
97
}