MAPG-10 refactor view-controller to be able to handle JSON response
This commit is contained in:
1 parent
55b693df68
commit
037d19b0b3
5 files changed
+73
-24
No files matched your search
@@ -1,24 +0,0 @@
|
||||
<?php namespace MapGuesser\Controller;
|
||||
|
||||
abstract class BaseController
|
||||
{
|
||||
protected string $view;
|
||||
|
||||
protected array $variables = [];
|
||||
|
||||
public function render() : string
|
||||
{
|
||||
$this->operate();
|
||||
|
||||
extract($this->variables);
|
||||
|
||||
ob_start();
|
||||
require ROOT . '/views/' . $this->view . '.php';
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
abstract protected function operate() : void;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace MapGuesser\Controller;
|
||||
|
||||
use MapGuesser\View\ViewBase;
|
||||
|
||||
interface ControllerInterface
|
||||
{
|
||||
public function run(): ViewBase;
|
||||
}
|
||||
Reference in new issue
Block a user