MAPG-3 create basic contoller functionality

This commit is contained in:
bence committed 2020-05-17 22:30:22 +02:00
1 parent c63f05295e
commit 555984caf5
5 files changed
+70 -1

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
<?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;
}
+22
View File
@@ -0,0 +1,22 @@
<?php namespace MapGuesser\Controller;
use MapGuesser\Util\Geo\Bounds;
use MapGuesser\Util\Geo\Position;
class GuessController extends BaseController
{
protected string $view = 'guess';
protected function operate() : void
{
// demo position
$realPosition = new Position(47.85239, 13.35101);
// demo bounds
$bounds = new Bounds($realPosition);
$bounds->extend(new Position(48.07683,7.35758));
$bounds->extend(new Position(47.57496, 19.08077));
$this->variables = compact('realPosition', 'bounds');
}
}