-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command to rebuild translations cache
- Loading branch information
1 parent
27c349e
commit 80c5ff1
Showing
4 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace MortenDHansen\LaravelDatabaseTranslations\Console; | ||
|
||
use MortenDHansen\LaravelDatabaseTranslations\DbTrans; | ||
use MortenDHansen\LaravelDatabaseTranslations\Models\DatabaseLangItem; | ||
|
||
class DatabaseTranslationsCacheCommand extends \Illuminate\Console\Command | ||
{ | ||
|
||
protected $signature = "dbtrans:cache-rebuild"; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Purge and rebuild cache for database translations'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$groups = DatabaseLangItem::all('group')->unique('group')->pluck('group'); | ||
$locales = DatabaseLangItem::all('locale')->unique('locale')->pluck('locale'); | ||
|
||
// build cache keys | ||
|
||
foreach ($groups as $group) { | ||
foreach ($locales as $locale) { | ||
\Cache::forget(DbTrans::getCacheKey($group, $locale)); | ||
DbTrans::getDatabaseTranslations($group, $locale); | ||
} | ||
} | ||
|
||
return self::SUCCESS; | ||
} | ||
|
||
public function buildCacheKeys() | ||
{ | ||
return $cacheKeys; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.