BuildTranslationsCacheCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 9.4285
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