Core MVC, HTTP client, Session, Cookie, Config, HTTPException — 111 PHPUnit tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
761 B
PHP
29 lines
761 B
PHP
<?php
|
|
/**
|
|
* @package Bicycle
|
|
* @author Egor Isaev
|
|
* @description Controller.php
|
|
* @copyright (c) 03/06/2026
|
|
*/
|
|
|
|
namespace System\Classes;
|
|
|
|
class Controller
|
|
{
|
|
protected string $_layout = 'layout';
|
|
|
|
/**
|
|
* @throws MyException
|
|
*/
|
|
protected function render(string $template, array $data = [], string $dir = ''): string
|
|
{
|
|
if ($dir === '') {
|
|
$class = substr(get_class($this), strlen('App\\Controller\\')); // [Admin\]FooController
|
|
$dir = 'view/' . str_replace('\\', '/', substr($class, 0, -10)); // view/[Admin/]Foo
|
|
}
|
|
|
|
return (new View($this->_layout, 'view/views', [
|
|
'content' => (new View($template, $dir, $data))->render()
|
|
]))->render();
|
|
}
|
|
} |