-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModuleOptimizeClearCommand.php
More file actions
59 lines (48 loc) · 1.32 KB
/
ModuleOptimizeClearCommand.php
File metadata and controls
59 lines (48 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare(strict_types=1);
namespace PanicDevs\Modules\Console;
use Illuminate\Console\Command;
use PanicDevs\Modules\ManifestBuilder;
/**
* ModuleOptimizeClearCommand
*
* Clears module optimization cache.
* This command is automatically called by Laravel's `optimize:clear` command.
*
* @package PanicDevs\Modules\Console
* @author PanicDevs
* @since 1.0.0
*/
class ModuleOptimizeClearCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'modules:clear';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear the cached module manifest';
/**
* Execute the console command.
*/
public function handle(ManifestBuilder $manifestBuilder): int
{
$this->info('Clearing module cache...');
$cacheFile = base_path('bootstrap/cache/modules.php');
if (!file_exists($cacheFile))
{
$this->info('Module cache does not exist.');
return self::SUCCESS;
}
// Clear the cache using ManifestBuilder
$manifestBuilder->clear();
$this->info('Module cache cleared successfully!');
$this->line("- Removed: <fg=blue>{$cacheFile}</>");
return self::SUCCESS;
}
}