1 | <?php |
||
7 | class Module extends \yii\base\Module |
||
8 | { |
||
9 | protected $_storage; |
||
10 | |||
11 | public $handlers = [ |
||
12 | 'md' => \hiqdev\yii2\modules\pages\models\MarkdownPage::class, |
||
13 | 'php' => \hiqdev\yii2\modules\pages\models\PhpPage::class, |
||
14 | 'twig' => \hiqdev\yii2\modules\pages\models\TwigPage::class, |
||
15 | ]; |
||
16 | |||
17 | /** |
||
18 | * This to use standard app pathes for views and layouts. |
||
19 | * @return string |
||
20 | */ |
||
21 | public function getViewPath() |
||
25 | |||
26 | public function find($page) |
||
27 | { |
||
28 | if ($this->getStorage()->has($page)) { |
||
29 | return $page; |
||
30 | } |
||
31 | |||
32 | foreach (array_keys($this->handlers) as $extension) { |
||
33 | $path = $page . '.' . $extension; |
||
34 | if ($this->getStorage()->has($path)) { |
||
35 | return $path; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | return null; |
||
40 | } |
||
41 | |||
42 | public function getMetadata($page) |
||
43 | { |
||
44 | return $this->getStorage()->getMetadata($page); |
||
45 | } |
||
46 | |||
47 | public function localPath($path) |
||
53 | |||
54 | /** |
||
55 | * Reads given path as array of already rtrimmed lines. |
||
56 | */ |
||
57 | public function readArray($path) |
||
62 | |||
63 | public function setStorage($value) |
||
67 | |||
68 | public function getStorage() |
||
76 | } |
||
77 |