|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Aura\View Provider for Aura\Di |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 5 |
|
6
|
|
|
* |
|
7
|
|
|
* Copyright (C) 2016 Jake Johns |
|
8
|
|
|
* |
|
9
|
|
|
* This software may be modified and distributed under the terms |
|
10
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
11
|
|
|
* |
|
12
|
|
|
* @category Config |
|
13
|
|
|
* @package Fusible\ViewProvider |
|
14
|
|
|
* @author Jake Johns <[email protected]> |
|
15
|
|
|
* @copyright 2016 Jake Johns |
|
16
|
|
|
* @license http://jnj.mit-license.org/2016 MIT License |
|
17
|
|
|
* @link https://github.com/fusible/fusible.view-provider |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Fusible\ViewProvider; |
|
21
|
|
|
|
|
22
|
|
|
use Aura\Di\Container; |
|
23
|
|
|
use Aura\Di\ContainerConfig; |
|
24
|
|
|
|
|
25
|
|
|
use Aura\Html; |
|
26
|
|
|
use Aura\View; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Config |
|
30
|
|
|
* |
|
31
|
|
|
* @category Config |
|
32
|
|
|
* @package Fusible\ViewProvider |
|
33
|
|
|
* @author Jake Johns <[email protected]> |
|
34
|
|
|
* @license http://jnj.mit-license.org/2016 MIT License |
|
35
|
|
|
* @link https://github.com/fusible/fusible.view-provider |
|
36
|
|
|
* |
|
37
|
|
|
* @see ContainerConfig |
|
38
|
|
|
*/ |
|
39
|
|
|
class ViewConfig extends ContainerConfig |
|
40
|
|
|
{ |
|
41
|
|
|
protected $values = [ |
|
42
|
|
|
ViewMap::class => [], |
|
43
|
|
|
ViewPaths::class => [], |
|
44
|
|
|
LayoutMap::class => [], |
|
45
|
|
|
LayoutPaths::class => [] |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* SetTemplatePath |
|
50
|
|
|
* |
|
51
|
|
|
* @param mixed $path DESCRIPTION |
|
52
|
|
|
* |
|
53
|
|
|
* @return mixed |
|
54
|
|
|
* |
|
55
|
|
|
* @access public |
|
56
|
|
|
*/ |
|
57
|
|
|
public function addTemplatePath($path) |
|
58
|
|
|
{ |
|
59
|
|
|
$this->values[ViewPaths::class][] = $path . '/views'; |
|
60
|
|
|
$this->values[LayoutPaths::class][] = $path . '/layouts'; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Define Aura\View and Aura\Html factories and services |
|
65
|
|
|
* |
|
66
|
|
|
* @param Container $di DI Container |
|
67
|
|
|
* |
|
68
|
|
|
* @return void |
|
69
|
|
|
* |
|
70
|
|
|
* @access public |
|
71
|
|
|
* |
|
72
|
|
|
* @SuppressWarnings(PHPMD.ShortVariable) |
|
73
|
|
|
*/ |
|
74
|
|
|
public function define(Container $di) |
|
75
|
|
|
{ |
|
76
|
|
|
foreach ($this->values as $key => $value) { |
|
77
|
|
|
$di->values[$key] = array_merge( |
|
78
|
|
|
$value, $di->values[$key] ?? [] |
|
79
|
|
|
); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$di->set( |
|
83
|
|
|
View\ViewFactory::class, |
|
84
|
|
|
$di->lazyNew(View\ViewFactory::class) |
|
85
|
|
|
); |
|
86
|
|
|
|
|
87
|
|
|
$di->set( |
|
88
|
|
|
View\View::class, |
|
89
|
|
|
$di->lazyGetCall( |
|
90
|
|
|
View\ViewFactory::class, |
|
91
|
|
|
'newInstance', |
|
92
|
|
|
$di->lazyGet(Html\HelperLocator::class), |
|
93
|
|
|
$di->lazyValue(ViewMap::class), |
|
94
|
|
|
$di->lazyValue(ViewPaths::class), |
|
95
|
|
|
$di->lazyValue(LayoutMap::class), |
|
96
|
|
|
$di->lazyValue(LayoutPaths::class) |
|
97
|
|
|
) |
|
98
|
|
|
); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|