|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\app\Console\Commands\Upgrade\v7\Steps; |
|
4
|
|
|
|
|
5
|
|
|
use Backpack\CRUD\app\Console\Commands\Upgrade\Step; |
|
6
|
|
|
use Backpack\CRUD\app\Console\Commands\Upgrade\StepResult; |
|
7
|
|
|
use Backpack\CRUD\app\Console\Commands\Upgrade\StepStatus; |
|
8
|
|
|
|
|
9
|
|
|
class CheckListOperationViewPublishedStep extends Step |
|
10
|
|
|
{ |
|
11
|
|
|
protected string $relativePath = 'resources/views/vendor/backpack/crud/list.blade.php'; |
|
12
|
|
|
|
|
13
|
|
|
public function title(): string |
|
14
|
|
|
{ |
|
15
|
|
|
return 'Published list operation view'; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function run(): StepResult |
|
19
|
|
|
{ |
|
20
|
|
|
if (! $this->context()->fileExists($this->relativePath)) { |
|
21
|
|
|
return StepResult::success('List operation view is not published, package default will be used.'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
return StepResult::warning( |
|
25
|
|
|
'A published list.blade.php was found. The bundled view received significant updates; delete the published copy to use the latest Backpack version.', |
|
26
|
|
|
["Published view: {$this->relativePath}"] |
|
27
|
|
|
); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function canFix(StepResult $result): bool |
|
31
|
|
|
{ |
|
32
|
|
|
return $result->status === StepStatus::Warning && $this->context()->fileExists($this->relativePath); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function fixMessage(StepResult $result): string |
|
36
|
|
|
{ |
|
37
|
|
|
return 'We can delete the published list.blade.php so Backpack uses the updated bundled view. Proceed?'; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function fix(StepResult $result): StepResult |
|
41
|
|
|
{ |
|
42
|
|
|
if (! $this->context()->fileExists($this->relativePath)) { |
|
43
|
|
|
return StepResult::skipped('Published list.blade.php was already removed.'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if (! $this->context()->deleteFile($this->relativePath)) { |
|
47
|
|
|
return StepResult::failure("Could not delete {$this->relativePath} automatically."); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return StepResult::success('Removed the published list.blade.php so the package view is used.'); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|