Completed
Pull Request — develop (#716)
by Agel_Nash
06:30
created

ManagerTheme::getSnippet()   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 namespace EvolutionCMS;
2
3
use EvolutionCMS\Interfaces\ManagerThemeInterface;
4
use EvolutionCMS\Interfaces\CoreInterface;
5
6
class ManagerTheme implements ManagerThemeInterface
7
{
8
    /**
9
     * @var CoreInterface
10
     */
11
    protected $core;
12
13
    /**
14
     * @var $theme
15
     */
16
    protected $theme;
17
18
    public function __construct(CoreInterface $core, $theme = '')
19
    {
20
        $this->core = $core;
21
22
        if (empty($theme)) {
23
            $theme = $this->core->getConfig('manager_theme');
24
        }
25
26
        $this->theme = $theme;
27
28
        $this->loadSnippets();
29
    }
30
31
    public function loadSnippets()
32
    {
33
        $this->core->addSnippet('recentInfoList', $this->pathElement('snippet', 'welcome/RecentInfo'));
34
    }
35
36
    public function pathSnippet($name)
37
    {
38
        return MODX_MANAGER_PATH . sprintf('media/style/%s/chunks/%s.tpl', $this->theme, $name);
39
    }
40
41
    public function pathElement($type, $name)
42
    {
43
        return MODX_MANAGER_PATH . sprintf('media/style/%s/%s/%s.tpl', $this->theme, $type, $name);
44
    }
45
46
    public function getElement($type, $name)
47
    {
48
        return file_get_contents($this->pathElement($type, $name));
49
    }
50
51
    public function getSnippet($name)
52
    {
53
        return $this->getElement('snippets', $name);
54
    }
55
56
    public function getChunk($name)
57
    {
58
        return $this->getElement('chunks', $name);
59
    }
60
}
61