# ecom: core/tools/AHttpController.php Source File

All Data Structures Namespaces Files Functions Variables
AHttpController.php
Go to the documentation of this file.
<?php
namespace Tools;
abstract class AHttpController extends AController
{
private $theme;
private $output;
public function __construct($context, $params)
{
parent::__construct($context, $params);
$this->output = new \Tools\Output($context);
$this->loadTheme();
}
private function loadTheme()
{
$themeName = \Entity\Config::getConfig(null, "theme", "default");
$themeDir = $this->context->router->themesPath.$themeName.'/';
if (!is_dir($themeDir))
throw new \Exception\Error404();
$this->theme = $themeDir;
}
public function start()
{
//TODO trigger hook GET, POST
//TODO call some hooks
$this->run();
//TODO calls some hooks
}
protected function render($viewFile)
{
$themedir = opendir($this->theme);
$exists = false;
while ($dir = readdir($themedir))
{
if ($dir !== $viewFile || is_dir($this->theme.'/'.$dir))
continue;
$exists = $dir;
}
closedir($themedir);
if ($exists === false)
return false;
$this->output->renderFile($this->theme . $exists);
return true;
}
public abstract function run();
public function __get($key)
{
if ($key === "theme")
return $this->theme;
throw new \Exception("Cannot access attribute {$key}");
}
}
Tools\AHttpController\start
start()
Definition: AHttpController.php:42
Tools\AHttpController
Definition: AHttpController.php:5
Tools\AHttpController\$theme
$theme
Definition: AHttpController.php:12
Entity\Config\getConfig
static getConfig($lang=null, $key=null, $defaultValue=null)
Definition: Config.php:44
Tools\AHttpController\loadTheme
loadTheme()
Definition: AHttpController.php:30
Tools\AHttpController\render
render($viewFile)
Definition: AHttpController.php:55
Tools
Definition: AController.php:3
Tools\AHttpController\$output
$output
Definition: AHttpController.php:18
Tools\AHttpController\__get
__get($key)
Definition: AHttpController.php:74
Tools\AHttpController\__construct
__construct($context, $params)
Definition: AHttpController.php:20
Tools\AController
Definition: AController.php:8