BuildTranslationsCacheCommand::fire()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 3
b 0
f 0
nc 3
nop 0
dl 0
loc 9
rs 9.6666
1
<?php namespace Modules\Translation\Console;
2
3
use Illuminate\Console\Command;
4
use Illuminate\Foundation\Bus\DispatchesJobs;
5
use Modules\Translation\Repositories\TranslationRepository;
6
7
class BuildTranslationsCacheCommand extends Command
8
{
9
    use DispatchesJobs;
10
11
    protected $name = 'asgard:build:translations';
12
    protected $description = 'Build the translations cache';
13
    /**
14
     * @var
15
     */
16
    private $translation;
17
18
    public function __construct(TranslationRepository $translation)
19
    {
20
        parent::__construct();
21
        $this->translation = $translation;
22
    }
23
24
    public function fire()
25
    {
26
        foreach ($this->translation->all() as $translation) {
27
            foreach (config('laravellocalization.supportedLocales') as $locale => $language) {
28
                $this->translation->findByKeyAndLocale($translation->key, $locale);
29
            }
30
        }
31
        $this->info('All translations were cached.');
32
    }
33
}
34