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\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use RuntimeException;
8
use Symfony\Component\Console\Attribute\AsCommand;
9
 
10
#[AsCommand(name: 'view:clear')]
11
class ViewClearCommand extends Command
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'view:clear';
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 = 'view:clear';
30
 
31
    /**
32
     * The console command description.
33
     *
34
     * @var string
35
     */
36
    protected $description = 'Clear all compiled view files';
37
 
38
    /**
39
     * The filesystem instance.
40
     *
41
     * @var \Illuminate\Filesystem\Filesystem
42
     */
43
    protected $files;
44
 
45
    /**
46
     * Create a new config clear command instance.
47
     *
48
     * @param  \Illuminate\Filesystem\Filesystem  $files
49
     * @return void
50
     */
51
    public function __construct(Filesystem $files)
52
    {
53
        parent::__construct();
54
 
55
        $this->files = $files;
56
    }
57
 
58
    /**
59
     * Execute the console command.
60
     *
61
     * @return void
62
     *
63
     * @throws \RuntimeException
64
     */
65
    public function handle()
66
    {
67
        $path = $this->laravel['config']['view.compiled'];
68
 
69
        if (! $path) {
70
            throw new RuntimeException('View path not found.');
71
        }
72
 
73
        $this->laravel['view.engine.resolver']
74
            ->resolve('blade')
75
            ->forgetCompiledOrNotExpired();
76
 
77
        foreach ($this->files->glob("{$path}/*") as $view) {
78
            $this->files->delete($view);
79
        }
80
 
81
        $this->components->info('Compiled views cleared successfully.');
82
    }
83
}