TwigExtension::getGlobals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace FOA\CronBundle\Twig;
4
5
/**
6
 * @author Novikov Viktor
7
 */
8
class TwigExtension extends \Twig_Extension
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $wwwUser;
14
15
    /**
16
     * @var string
17
     */
18
    protected $logDir;
19
20
    /**
21
     * @var string
22
     */
23
    protected $symfonyCommand;
24
25
    /**
26
     * @param string $logDir
27
     * @param string $kernelDir
28
     */
29
    public function __construct($logDir, $kernelDir)
30
    {
31
        if (function_exists('posix_getpwuid')) {
32
            $this->wwwUser = posix_getpwuid(posix_geteuid());
33
        } else {
34
            $this->wwwUser = [
35
                'name' => get_current_user(),
36
                'dir'  => '-',
37
            ];
38
        }
39
        $this->logDir = $logDir;
40
        $this->symfonyCommand = 'php ' . $kernelDir . '/console';
41
    }
42
43
    /**
44
     * @return string[]
45
     */
46
    public function getGlobals()
47
    {
48
        return [
49
            'wwwUser'        => $this->wwwUser,
50
            'logDir'         => $this->logDir,
51
            'symfonyCommand' => $this->symfonyCommand,
52
        ];
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getName()
59
    {
60
        return 'bcc-cron-manager';
61
    }
62
}
63