1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the "andrey-helldar/laravel-lang-publisher" project. |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* @author Andrey Helldar <[email protected]> |
10
|
|
|
* |
11
|
|
|
* @copyright 2021 Andrey Helldar |
12
|
|
|
* |
13
|
|
|
* @license MIT |
14
|
|
|
* |
15
|
|
|
* @see https://github.com/andrey-helldar/laravel-lang-publisher |
16
|
|
|
*/ |
17
|
|
|
|
18
|
4 |
|
declare(strict_types=1); |
19
|
|
|
|
20
|
4 |
|
namespace Helldar\LaravelLangPublisher\Console; |
21
|
|
|
|
22
|
4 |
|
use Helldar\LaravelLangPublisher\Facades\Helpers\Locales; |
23
|
4 |
|
use Helldar\Support\Facades\Helpers\Filesystem\Directory; |
24
|
|
|
use Helldar\Support\Facades\Helpers\Filesystem\File; |
25
|
4 |
|
|
26
|
|
|
class Remove extends Base |
27
|
4 |
|
{ |
28
|
|
|
protected $signature = 'lang:rm' |
29
|
4 |
|
. ' {locales?* : Space-separated list of, eg: de tk it}'; |
30
|
|
|
|
31
|
4 |
|
protected $description = 'Remove localizations.'; |
32
|
|
|
|
33
|
4 |
|
protected $method = 'remove'; |
34
|
|
|
|
35
|
4 |
|
public function handle() |
36
|
|
|
{ |
37
|
4 |
|
foreach ($this->targetLocales() as $locale) { |
38
|
|
|
$this->removeDirectory($locale); |
39
|
|
|
$this->removeJson($locale); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function removeDirectory(string $locale): void |
44
|
|
|
{ |
45
|
|
|
$path = $this->resourcesPath($locale); |
46
|
|
|
|
47
|
|
|
Directory::ensureDelete($path); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
protected function removeJson(string $locale): void |
51
|
|
|
{ |
52
|
|
|
$path = $this->resourcesPath($locale . '.json'); |
53
|
|
|
|
54
|
|
|
File::ensureDelete($path); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
protected function targetLocales(): array |
58
|
|
|
{ |
59
|
|
|
return $this->askLocales($this->method); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
protected function getAllLocales(): array |
63
|
|
|
{ |
64
|
|
|
return Locales::installed(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|