| @@ 9-59 (lines=51) @@ | ||
| 6 | use Illuminate\Filesystem\Filesystem; |
|
| 7 | use RichanFongdasen\I18n\Traits\TranslatedRouteCommandContext; |
|
| 8 | ||
| 9 | class RouteTranslationsClearCommand extends Command |
|
| 10 | { |
|
| 11 | use TranslatedRouteCommandContext; |
|
| 12 | /** |
|
| 13 | * The console command name. |
|
| 14 | * |
|
| 15 | * @var string |
|
| 16 | */ |
|
| 17 | protected $name = 'route:trans:clear'; |
|
| 18 | /** |
|
| 19 | * The console command description. |
|
| 20 | * |
|
| 21 | * @var string |
|
| 22 | */ |
|
| 23 | protected $description = 'Remove the translated route cache files for each locale'; |
|
| 24 | /** |
|
| 25 | * The filesystem instance. |
|
| 26 | * |
|
| 27 | * @var \Illuminate\Filesystem\Filesystem |
|
| 28 | */ |
|
| 29 | protected $files; |
|
| 30 | /** |
|
| 31 | * Create a new route clear command instance. |
|
| 32 | * |
|
| 33 | * @param \Illuminate\Filesystem\Filesystem $files |
|
| 34 | */ |
|
| 35 | public function __construct(Filesystem $files) |
|
| 36 | { |
|
| 37 | parent::__construct(); |
|
| 38 | $this->files = $files; |
|
| 39 | } |
|
| 40 | /** |
|
| 41 | * Execute the console command. |
|
| 42 | * |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function handle() |
|
| 46 | { |
|
| 47 | foreach ($this->getSupportedLocales() as $locale) { |
|
| 48 | $path = $this->makeLocaleRoutesPath($locale); |
|
| 49 | if ($this->files->exists($path)) { |
|
| 50 | $this->files->delete($path); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | $path = $this->laravel->getCachedRoutesPath(); |
|
| 54 | if ($this->files->exists($path)) { |
|
| 55 | $this->files->delete($path); |
|
| 56 | } |
|
| 57 | $this->info('Route caches for locales cleared!'); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||
| @@ 9-59 (lines=51) @@ | ||
| 6 | use Illuminate\Filesystem\Filesystem; |
|
| 7 | use RichanFongdasen\I18n\Traits\TranslatedRouteCommandContext; |
|
| 8 | ||
| 9 | class RouteTranslationsClearCommand extends Command |
|
| 10 | { |
|
| 11 | use TranslatedRouteCommandContext; |
|
| 12 | /** |
|
| 13 | * The console command name. |
|
| 14 | * |
|
| 15 | * @var string |
|
| 16 | */ |
|
| 17 | protected $name = 'route:trans:clear'; |
|
| 18 | /** |
|
| 19 | * The console command description. |
|
| 20 | * |
|
| 21 | * @var string |
|
| 22 | */ |
|
| 23 | protected $description = 'Remove the translated route cache files for each locale'; |
|
| 24 | /** |
|
| 25 | * The filesystem instance. |
|
| 26 | * |
|
| 27 | * @var \Illuminate\Filesystem\Filesystem |
|
| 28 | */ |
|
| 29 | protected $files; |
|
| 30 | /** |
|
| 31 | * Create a new route clear command instance. |
|
| 32 | * |
|
| 33 | * @param \Illuminate\Filesystem\Filesystem $files |
|
| 34 | */ |
|
| 35 | public function __construct(Filesystem $files) |
|
| 36 | { |
|
| 37 | parent::__construct(); |
|
| 38 | $this->files = $files; |
|
| 39 | } |
|
| 40 | /** |
|
| 41 | * Execute the console command. |
|
| 42 | * |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function handle() |
|
| 46 | { |
|
| 47 | foreach ($this->getSupportedLocales() as $locale => $localeValue) { |
|
| 48 | $path = $this->makeLocaleRoutesPath($locale); |
|
| 49 | if ($this->files->exists($path)) { |
|
| 50 | $this->files->delete($path); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | $path = $this->laravel->getCachedRoutesPath(); |
|
| 54 | if ($this->files->exists($path)) { |
|
| 55 | $this->files->delete($path); |
|
| 56 | } |
|
| 57 | $this->info('Route caches for locales cleared!'); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||