|
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\HelperLocatorFactory; |
|
26
|
|
|
use Aura\Html\EscaperFactory; |
|
27
|
|
|
use Aura\Html\Helper\AbstractHelper; |
|
28
|
|
|
use Aura\View\ViewFactory; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Config |
|
32
|
|
|
* |
|
33
|
|
|
* @category Config |
|
34
|
|
|
* @package Fusible\ViewProvider |
|
35
|
|
|
* @author Jake Johns <[email protected]> |
|
36
|
|
|
* @license http://jnj.mit-license.org/2016 MIT License |
|
37
|
|
|
* @link https://github.com/fusible/fusible.view-provider |
|
38
|
|
|
* |
|
39
|
|
|
* @see ContainerConfig |
|
40
|
|
|
*/ |
|
41
|
|
|
class Config extends ContainerConfig |
|
42
|
|
|
{ |
|
43
|
|
|
const VIEW_FACTORY = 'aura/view:factory'; |
|
44
|
|
|
const VIEW = 'aura/view:view'; |
|
45
|
|
|
const HTML_FACTORY = 'aura/html:factory'; |
|
46
|
|
|
const HTML_HELPERS = 'aura/html:helpers'; |
|
47
|
|
|
const HTML_ESCAPER = 'aura/html:escaper'; |
|
48
|
|
|
const HTML_ESCAPER_FACTORY = 'aura/html:escaper_factory'; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Define Aura\View and Aura\Html factories and services |
|
52
|
|
|
* |
|
53
|
|
|
* @param Container $di DI Container |
|
54
|
|
|
* |
|
55
|
|
|
* @return void |
|
56
|
|
|
* |
|
57
|
|
|
* @access public |
|
58
|
|
|
* |
|
59
|
|
|
* @SuppressWarnings(PHPMD.ShortVariable) |
|
60
|
|
|
*/ |
|
61
|
9 |
|
public function define(Container $di) |
|
62
|
|
|
{ |
|
63
|
|
|
// Aura\Html |
|
64
|
9 |
|
$di->set( |
|
65
|
9 |
|
static::HTML_FACTORY, |
|
66
|
9 |
|
$di->lazyNew(HelperLocatorFactory::class) |
|
67
|
9 |
|
); |
|
68
|
|
|
|
|
69
|
9 |
|
$di->set( |
|
70
|
9 |
|
static::HTML_HELPERS, |
|
71
|
9 |
|
$di->lazyGetCall( |
|
72
|
9 |
|
static::HTML_FACTORY, |
|
73
|
|
|
'newInstance' |
|
74
|
9 |
|
) |
|
75
|
9 |
|
); |
|
76
|
|
|
|
|
77
|
9 |
|
$di->set( |
|
78
|
9 |
|
static::HTML_ESCAPER_FACTORY, |
|
79
|
9 |
|
$di->lazyNew(EscaperFactory::class) |
|
80
|
9 |
|
); |
|
81
|
|
|
|
|
82
|
9 |
|
$di->set( |
|
83
|
9 |
|
static::HTML_ESCAPER, |
|
84
|
9 |
|
$di->lazyGetCall(static::HTML_ESCAPER_FACTORY, 'newInstance') |
|
85
|
9 |
|
); |
|
86
|
|
|
|
|
87
|
9 |
|
$di->params[AbstractHelper::class] = [ |
|
88
|
9 |
|
'escaper' => $di->lazyGet(static::HTML_ESCAPER) |
|
89
|
9 |
|
]; |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
// Aura\View |
|
93
|
9 |
|
$di->set( |
|
94
|
9 |
|
static::VIEW_FACTORY, |
|
95
|
9 |
|
$di->lazyNew(ViewFactory::class) |
|
96
|
9 |
|
); |
|
97
|
|
|
|
|
98
|
9 |
|
$di->set( |
|
99
|
9 |
|
static::VIEW, |
|
100
|
9 |
|
$di->lazyGetCall( |
|
101
|
9 |
|
static::VIEW_FACTORY, |
|
102
|
9 |
|
'newInstance', |
|
103
|
9 |
|
$di->lazyGet(static::HTML_HELPERS) |
|
104
|
9 |
|
) |
|
105
|
9 |
|
); |
|
106
|
|
|
|
|
107
|
9 |
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|