-
Notifications
You must be signed in to change notification settings - Fork 2
/
View.php
47 lines (40 loc) · 1.23 KB
/
View.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
<?php
/**
* Copyright (c) 2017. Alexandr Kosarev, @kosarev.by
*/
namespace Joomplace\X;
use \Joomla\CMS\MVC\View\HtmlView;
use Joomplace\X\Helper\Object;
use \Joomplace\X\Renderer\PlainPHP as JoomlaEngine;
use \Joomplace\X\Renderer\Edge as EdgeEngine;
class View extends HtmlView
{
use Object;
use EdgeEngine;
public function __construct(array $config = array())
{
if (isset($config['name'])) {
list($config['name'], $config['layout']) = explode(':', $config['name']);
}
if (!isset($config['base_path'])) {
$base_path = str_replace('//', '/', $this->getExecutedClassDirictory() . '/../../');
$config['base_path'] = $base_path;
$config['template_path'] = [
$base_path.'tmpl/',
__DIR__.'/../layouts',$config['base_path'].'tmpl/'.strtolower($config['name']),
];
}
parent::__construct($config);
}
public function getExecutedClassDirictory()
{
$reflector = new \ReflectionClass(get_class($this));
$fn = $reflector->getFileName();
return dirname($fn);
}
public function display($tpl = null)
{
$result = $this->render($tpl);
echo $result;
}
}