# ecom: AHttpController Class Reference

All Data Structures Namespaces Files Functions Variables
AHttpController Class Reference
Inheritance diagram for AHttpController:

## Public Member Functions

| __construct ($context, $params)
| start ()
| run ()
| __get ($key)
Public Member Functions inherited from AController
| __construct ($context, $params)
| start ()

## Protected Member Functions

| render ($viewFile)

## Private Member Functions

| loadTheme ()

## Private Attributes

| $theme
| $output

## Additional Inherited Members

Protected Attributes inherited from AController
| $params
| $context

## Detailed Description

Definition at line 5 of file AHttpController.php.

## Constructor & Destructor Documentation

__construct | ( |  | $context,
|  |  | $params
| ) |  |

Definition at line 20 of file AHttpController.php.

{
parent::__construct($context, $params);
$this->output = new \Tools\Output($context);
$this->loadTheme();
}
Tools\AHttpController\loadTheme
loadTheme()
Definition: AHttpController.php:30
Tools\AController\$params
$params
Definition: AController.php:18
Tools\AController\$context
$context
Definition: AController.php:23

## Member Function Documentation

__get | ( |  | $key | ) |

Definition at line 74 of file AHttpController.php.

{
if ($key === "theme")
return $this->theme;
throw new \Exception("Cannot access attribute {$key}");
}
Tools\AHttpController\$theme
$theme
Definition: AHttpController.php:12

loadTheme | ( |  | ) |

private

Init theme

Definition at line 30 of file AHttpController.php.

{
$themeName = \Entity\Config::getConfig(null, "theme", "default");
$themeDir = $this->context->router->themesPath.$themeName.'/';
if (!is_dir($themeDir))
throw new \Exception\Error404();
$this->theme = $themeDir;
}
Entity\Config\getConfig
static getConfig($lang=null, $key=null, $defaultValue=null)
Definition: Config.php:44

render | ( |  | $viewFile | ) |

protected

Load and render a file

Parameters

  string | $viewFile | template view to load (from theme)

Returns
  boolean true on success

Definition at line 55 of file AHttpController.php.

{
$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;
}

run | ( |  | ) |

abstract

start | ( |  | ) |

Run the controller. Entry point

Definition at line 42 of file AHttpController.php.

{
//TODO trigger hook GET, POST
//TODO call some hooks
$this->run();
//TODO calls some hooks
}
Tools\AHttpController\run
run()

## Field Documentation

Tools Output $output

private

Output manager

Definition at line 18 of file AHttpController.php.

string $theme

private

Theme's directory Accessible read-only

Definition at line 12 of file AHttpController.php.

The documentation for this class was generated from the following file:

- core/tools/AHttpController.php