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

ManagerTheme   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A loadSnippets() 0 4 1
A pathElement() 0 4 1
A pathSnippet() 0 4 1
A getElement() 0 4 1
A getSnippet() 0 4 1
A getChunk() 0 4 1
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