/
LaravelAdminCleaner.php
54 lines (47 loc) · 1.63 KB
/
LaravelAdminCleaner.php
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
<?php
namespace Hhxsv5\LaravelS\Illuminate\Cleaners;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Facade;
class LaravelAdminCleaner extends BaseCleaner
{
const ADMIN_CLASS = 'Encore\Admin\Admin';
private $reflection;
protected $properties = [
'deferredScript' => [],
'script' => [],
'style' => [],
'css' => [],
'js' => [],
'html' => [],
'headerJs' => [],
'manifest' => 'vendor/laravel-admin/minify-manifest.json',
'manifestData' => [],
'extensions' => [],
'minifyIgnores' => [],
'metaTitle' => null,
'favicon' => null,
'bootingCallbacks' => [],
'bootedCallbacks' => [],
];
public function __construct(Container $currentApp, Container $snapshotApp)
{
parent::__construct($currentApp, $snapshotApp);
$this->reflection = new \ReflectionClass(self::ADMIN_CLASS);
}
public function clean()
{
foreach ($this->properties as $name => $value) {
if ($this->reflection->hasProperty($name)) {
$property = $this->reflection->getProperty($name);
if ($property->isStatic()) {
if (!$property->isPublic()) {
$property->setAccessible(true);
}
$property->setValue($value);
}
}
}
$this->currentApp->forgetInstance(self::ADMIN_CLASS);
Facade::clearResolvedInstance(self::ADMIN_CLASS);
}
}