ecom
E-commerce cms
 All Data Structures Namespaces Files Functions Variables
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
AHttpController Class Reference
Inheritance diagram for AHttpController:
AController CategoryController HomeController

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.

21  {
22  parent::__construct($context, $params);
23  $this->output = new \Tools\Output($context);
24  $this->loadTheme();
25  }

Member Function Documentation

__get (   $key)

Definition at line 74 of file AHttpController.php.

75  {
76  if ($key === "theme")
77  return $this->theme;
78  throw new \Exception("Cannot access attribute {$key}");
79  }
loadTheme ( )
private

Init theme

Definition at line 30 of file AHttpController.php.

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

Load and render a file

Parameters
string$viewFiletemplate view to load (from theme)
Returns
boolean true on success

Definition at line 55 of file AHttpController.php.

56  {
57  $themedir = opendir($this->theme);
58  $exists = false;
59  while ($dir = readdir($themedir))
60  {
61  if ($dir !== $viewFile || is_dir($this->theme.'/'.$dir))
62  continue;
63  $exists = $dir;
64  }
65  closedir($themedir);
66  if ($exists === false)
67  return false;
68  $this->output->renderFile($this->theme . $exists);
69  return true;
70  }
run ( )
abstract
start ( )

Run the controller. Entry point

Definition at line 42 of file AHttpController.php.

43  {
44  //TODO trigger hook GET, POST
45  //TODO call some hooks
46  $this->run();
47  //TODO calls some hooks
48  }

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: