Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 150 | Zur aktuellen 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\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use Symfony\Component\Console\Attribute\AsCommand;
8
 
9
#[AsCommand(name: 'stub:publish')]
10
class StubPublishCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'stub:publish
18
                    {--existing : Publish and overwrite only the files that have already been published}
19
                    {--force : Overwrite any existing files}';
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 = 'stub:publish';
31
 
32
    /**
33
     * The console command description.
34
     *
35
     * @var string
36
     */
37
    protected $description = 'Publish all stubs that are available for customization';
38
 
39
    /**
40
     * Execute the console command.
41
     *
42
     * @return void
43
     */
44
    public function handle()
45
    {
46
        if (! is_dir($stubsPath = $this->laravel->basePath('stubs'))) {
47
            (new Filesystem)->makeDirectory($stubsPath);
48
        }
49
 
50
        $files = [
51
            __DIR__.'/stubs/cast.inbound.stub' => $stubsPath.'/cast.inbound.stub',
52
            __DIR__.'/stubs/cast.stub' => $stubsPath.'/cast.stub',
53
            __DIR__.'/stubs/console.stub' => $stubsPath.'/console.stub',
54
            __DIR__.'/stubs/event.stub' => $stubsPath.'/event.stub',
55
            __DIR__.'/stubs/job.queued.stub' => $stubsPath.'/job.queued.stub',
56
            __DIR__.'/stubs/job.stub' => $stubsPath.'/job.stub',
57
            __DIR__.'/stubs/mail.stub' => $stubsPath.'/mail.stub',
58
            __DIR__.'/stubs/markdown-mail.stub' => $stubsPath.'/markdown-mail.stub',
59
            __DIR__.'/stubs/markdown-notification.stub' => $stubsPath.'/markdown-notification.stub',
60
            __DIR__.'/stubs/model.pivot.stub' => $stubsPath.'/model.pivot.stub',
61
            __DIR__.'/stubs/model.stub' => $stubsPath.'/model.stub',
62
            __DIR__.'/stubs/notification.stub' => $stubsPath.'/notification.stub',
63
            __DIR__.'/stubs/observer.plain.stub' => $stubsPath.'/observer.plain.stub',
64
            __DIR__.'/stubs/observer.stub' => $stubsPath.'/observer.stub',
65
            __DIR__.'/stubs/policy.plain.stub' => $stubsPath.'/policy.plain.stub',
66
            __DIR__.'/stubs/policy.stub' => $stubsPath.'/policy.stub',
67
            __DIR__.'/stubs/provider.stub' => $stubsPath.'/provider.stub',
68
            __DIR__.'/stubs/request.stub' => $stubsPath.'/request.stub',
69
            __DIR__.'/stubs/resource.stub' => $stubsPath.'/resource.stub',
70
            __DIR__.'/stubs/resource-collection.stub' => $stubsPath.'/resource-collection.stub',
71
            __DIR__.'/stubs/rule.stub' => $stubsPath.'/rule.stub',
72
            __DIR__.'/stubs/scope.stub' => $stubsPath.'/scope.stub',
73
            __DIR__.'/stubs/test.stub' => $stubsPath.'/test.stub',
74
            __DIR__.'/stubs/test.unit.stub' => $stubsPath.'/test.unit.stub',
75
            __DIR__.'/stubs/view-component.stub' => $stubsPath.'/view-component.stub',
76
            realpath(__DIR__.'/../../Database/Console/Factories/stubs/factory.stub') => $stubsPath.'/factory.stub',
77
            realpath(__DIR__.'/../../Database/Console/Seeds/stubs/seeder.stub') => $stubsPath.'/seeder.stub',
78
            realpath(__DIR__.'/../../Database/Migrations/stubs/migration.create.stub') => $stubsPath.'/migration.create.stub',
79
            realpath(__DIR__.'/../../Database/Migrations/stubs/migration.stub') => $stubsPath.'/migration.stub',
80
            realpath(__DIR__.'/../../Database/Migrations/stubs/migration.update.stub') => $stubsPath.'/migration.update.stub',
81
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.api.stub') => $stubsPath.'/controller.api.stub',
82
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.invokable.stub') => $stubsPath.'/controller.invokable.stub',
83
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.model.api.stub') => $stubsPath.'/controller.model.api.stub',
84
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.model.stub') => $stubsPath.'/controller.model.stub',
85
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.nested.api.stub') => $stubsPath.'/controller.nested.api.stub',
86
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.nested.singleton.api.stub') => $stubsPath.'/controller.stub',
87
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.nested.singleton.stub') => $stubsPath.'/controller.stub',
88
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.nested.stub') => $stubsPath.'/controller.nested.stub',
89
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.plain.stub') => $stubsPath.'/controller.plain.stub',
90
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.singleton.api.stub') => $stubsPath.'/controller.stub',
91
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.singleton.stub') => $stubsPath.'/controller.stub',
92
            realpath(__DIR__.'/../../Routing/Console/stubs/controller.stub') => $stubsPath.'/controller.stub',
93
            realpath(__DIR__.'/../../Routing/Console/stubs/middleware.stub') => $stubsPath.'/middleware.stub',
94
        ];
95
 
96
        foreach ($files as $from => $to) {
97
            if ((! $this->option('existing') && (! file_exists($to) || $this->option('force')))
98
                || ($this->option('existing') && file_exists($to))) {
99
                file_put_contents($to, file_get_contents($from));
100
            }
101
        }
102
 
103
        $this->components->info('Stubs published successfully.');
104
    }
105
}