MediaLibraryModuleServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace ByTIC\MediaLibraryModule;
4
5
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
6
use Nip\Container\ServiceProviders\Providers\BootableServiceProviderInterface;
7
8
/**
9
 * Class MediaLibraryModuleServiceProvider.
10
 */
11
class MediaLibraryModuleServiceProvider extends AbstractSignatureServiceProvider implements BootableServiceProviderInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function provides()
17
    {
18
        return [];
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function register()
25
    {
26
    }
27
28
    public function boot()
29
    {
30
        $this->registerResources();
31
    }
32
33
    protected function registerResources()
34
    {
35
        $folder = __DIR__ . '/resources/lang/';
36
        $languages = $this->getContainer()->get('translation.languages');
37
38
        $translator = $this->getContainer()->get('translator');
39
40
        foreach ($languages as $language) {
41
            $path = $folder . $language;
42
            if (is_dir($path)) {
43
                $translator->addResource('php', $path, $language);
44
            }
45
        }
46
    }
47
}
48