Completed
Push — EZP-26835-load-translation-pac... ( f96c61 )
by Nicolas
15:15
created

Collector::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the Collector class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishCoreBundle\Translation;
10
11
/**
12
 * Retrieve all ezplatform translation files installed
13
 */
14
class Collector
15
{
16
    /**
17
     * @var
18
     */
19
    protected $tranlationPattern;
20
21
    /**
22
     * @param string $kernelRootDir
23
     */
24
    public function __construct($kernelRootDir)
25
    {
26
        $this->tranlationPattern = $kernelRootDir . '/../vendor/ezsystems/ezplatform-i18n-*/*/*.xlf';
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function collect()
33
    {
34
        $files = glob($this->tranlationPattern);
35
        $meta = [];
36
37
        foreach ($files as $file) {
38
            list($domain, $locale, $format) = explode('.', basename($file), 3);
39
            $meta[] = [
40
                'file'   => $file,
41
                'domain' => $domain,
42
                'locale' => $locale,
43
                'format' => $format
44
            ];
45
        }
46
47
        return $meta;
48
    }
49
}
50