-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.php
35 lines (27 loc) · 1.13 KB
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// Global Functions
// You can add your global functions here
/**
* View function for rendering blade templates
*
* @param string $file
* @param array $data
*/
function view($file, $data)
{
$pathToTemplates = [__DIR__ . '/resources/views'];
$pathToCompiledTemplates = __DIR__ . '/cache/views';
$fileSystem = new \Illuminate\Filesystem\Filesystem;
$events = new \Illuminate\Events\Dispatcher(new \Illuminate\Container\Container);
$viewResolver = new \Illuminate\View\Engines\EngineResolver;
$bladeCompiler = new \Illuminate\View\Compilers\BladeCompiler($fileSystem, $pathToCompiledTemplates);
$viewResolver->register('blade', function() use ($bladeCompiler, $fileSystem) {
return new \Illuminate\View\Engines\CompilerEngine($bladeCompiler, $fileSystem);
});
$viewResolver->register('php', function() {
return new \Illuminate\View\Engines\PhpEngine;
});
$viewFinder = new \Illuminate\View\FileViewFinder($fileSystem, $pathToTemplates);
$viewFactory = new Illuminate\View\Factory($viewResolver, $viewFinder, $events);
echo $viewFactory->make($file, $data)->render();
}