moved templatePath into constructor
This commit is contained in:
@@ -3,11 +3,15 @@ namespace src\Controller;
|
||||
|
||||
abstract class BaseController
|
||||
{
|
||||
public function __construct(
|
||||
string $templatePath = __DIR__ . '/../../templates/'
|
||||
) {}
|
||||
|
||||
protected function render(string $view, array $data = []): void
|
||||
{
|
||||
extract($data);
|
||||
|
||||
$viewPath = __DIR__ . '/../../templates/' . $view . '.php';
|
||||
$viewPath = $this->templatePath . '/' . $view . '.php';
|
||||
|
||||
if (!file_exists($viewPath)) {
|
||||
http_response_code(500);
|
||||
|
||||
Reference in New Issue
Block a user