1 | <?php |
||
8 | class BladeProvider |
||
9 | { |
||
10 | /** |
||
11 | * Path to a folder view common view can be stored. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected static $baseViewPath; |
||
16 | |||
17 | /** |
||
18 | * Local path to blade cache storage. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected static $cachePath; |
||
23 | |||
24 | /** |
||
25 | * View factory. |
||
26 | * |
||
27 | * @var Factory |
||
28 | */ |
||
29 | protected static $viewFactory; |
||
30 | |||
31 | /** |
||
32 | * Service container factory. |
||
33 | * |
||
34 | * @var Container |
||
35 | */ |
||
36 | protected static $container; |
||
37 | |||
38 | /** |
||
39 | * Register blade engine in Bitrix. |
||
40 | * |
||
41 | * @param string $baseViewPath |
||
42 | * @param string $cachePath |
||
43 | */ |
||
44 | public static function register($baseViewPath = 'local/views', $cachePath = 'bitrix/cache/blade') |
||
59 | |||
60 | /** |
||
61 | * Get view factory. |
||
62 | * |
||
63 | * @return Factory |
||
64 | */ |
||
65 | public static function getViewFactory() |
||
69 | |||
70 | /** |
||
71 | * @return BladeCompiler |
||
72 | */ |
||
73 | public function getCompiler() |
||
77 | |||
78 | /** |
||
79 | * Update paths where blade tries to find additional views. |
||
80 | * |
||
81 | * @param string $templateDir |
||
82 | */ |
||
83 | public static function updateViewPaths($templateDir) |
||
93 | |||
94 | /** |
||
95 | * Instantiate service container if it's not instantiated yet. |
||
96 | */ |
||
97 | protected static function instantiateServiceContainer() |
||
108 | |||
109 | /** |
||
110 | * Instantiate view factory. |
||
111 | */ |
||
112 | protected static function instantiateViewFactory() |
||
127 | |||
128 | /** |
||
129 | * Create dir if it does not exist. |
||
130 | * |
||
131 | * @param string $path |
||
132 | */ |
||
133 | protected static function createDirIfNotExist($path) |
||
141 | |||
142 | /** |
||
143 | * Register bitrix directives. |
||
144 | */ |
||
145 | protected static function registerBitrixDirectives() |
||
155 | } |
||
156 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: