-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlock.php
71 lines (60 loc) · 1.81 KB
/
Block.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Mods\View;
use Layout\Core\Contracts\Profiler;
use Illuminate\View\ViewFinderInterface;
use Layout\Core\Contracts\ConfigResolver;
use Illuminate\Contracts\Container\Container;
use Layout\Core\Contracts\Cacheable as Cache;
use Layout\Core\Block\AbstractBlock as BaseBlock;
use Layout\Core\Contracts\EventsDispatcher as Dispatcher;
abstract class Block extends BaseBlock
{
/**
* Container Instance
*
* @var \Illuminate\Contracts\Container\Container
*/
public $app;
/**
* Create a new view factory instance.
*
* @param \Illuminate\Contracts\Container\Container $app
* @param \Layout\Core\Contracts\Cacheable $cache
* @param \Layout\Core\Contracts\ConfigResolver $config
* @param \Layout\Core\Contracts\EventsDispatcher $events
* @param \Layout\Core\Contracts\Profiler $profiler
*/
public function __construct(
Container $app,
Cache $cache,
ConfigResolver $config,
Dispatcher $events,
Profiler $profiler
) {
$this->app = $app;
parent::__construct($cache, $config, $events, $profiler);
}
/**
* Get relevant path to template.
*
* @return string
*/
public function getTemplate()
{
if(is_null($this->template)) {
return null;
}
$section = $this->config->get('handle_layout_section');
$template = explode(ViewFinderInterface::HINT_PATH_DELIMITER, $this->template);
if (count($template) == 2) {
$template = "{$template[0]}_$section::{$template[1]}";
} else {
$template = "$section::{$template[0]}";
}
return $template;
}
protected function getView($fileName, $viewVars)
{
return app('view')->make($fileName, $viewVars)->render();
}
}