Refactor classes into Http structure
This commit is contained in:
parent
83bc1a1661
commit
591e0c194d
9 changed files with 25 additions and 25 deletions
28
src/Http/View/Engine/HtmlEngine.php
Normal file
28
src/Http/View/Engine/HtmlEngine.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Core\Http\View\Engine;
|
||||
|
||||
use Core\Http\View\Engine;
|
||||
|
||||
class HtmlEngine extends Render
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function render(): void
|
||||
{
|
||||
$basePath = $_SERVER['DOCUMENT_ROOT'];
|
||||
$viewsPath = app()->resourcePath('views/' . str_replace('.', '/', $this->view) . '.php');
|
||||
|
||||
if (file_exists($viewsPath)) {
|
||||
extract($this->data);
|
||||
|
||||
include $viewsPath;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new \Exception('View not found');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue