All Data Structures Namespaces Files Functions Variables
Context Class Reference

## Public Member Functions

| __construct ($server=null)
| serve ()
| run ()
| __get ($key)
| isTestingEnvironment ()

## Static Public Member Functions

static | getContext ()

## Private Attributes

| $hookManager
| $moduleManager
| $router
| $cart
| $user
| $controller
| $ip
| $server

## Static Private Attributes

static | $instance

## Detailed Description

Cms context Contains all website informations Will be passed to themes files and to modules

Definition at line 10 of file Context.php.

## Constructor & Destructor Documentation

__construct | ( |  | $server = `null` | ) |

Create context from $_SERVER environment and initialize all data

Parameters

  array | $server | optional, contains $_SERVER configuration -> REMOTE_ADDR client's ip -> SCRIPT_NAME -> DOCUMENT_ROOT -> REQUEST_SCHEME 'http:https' -> REQUEST_URI -> HTTP_HOST

Definition at line 90 of file Context.php.

{
self::$instance = $this;
if ($server == null)
$server = $_SERVER;
$this->ip = $server["REMOTE_ADDR"];
$this->hookManager = new Hooks($this);
$this->server = $server;
$this->router = new Router($this->server, $this);
}
Tools\Context\$server
$server
Definition: Context.php:77

## Member Function Documentation

__get | ( |  | $key | ) |

Getter function

Definition at line 137 of file Context.php.

{
switch ($key)
{
case "router": return $this->router; break;
case "cart": return $this->cart; break;
case "user": return $this->user; break;
case "moduleManager": return $this->moduleManager; break;
case "hookManager": return $this->hookManager; break;
case "ip": return $this->ip; break;
case "controller": return $this->controller; break;
}
throw new \Exception("Cannot access attribute {$key}");
}
Tools\Context\$user
$user
Definition: Context.php:57
Tools\Context\$cart
$cart
Definition: Context.php:49
Tools\Context\$hookManager
$hookManager
Definition: Context.php:18
Tools\Context\$moduleManager
$moduleManager
Definition: Context.php:31
Tools\Context\$router
$router
Definition: Context.php:40
Tools\Context\$controller
$controller
Definition: Context.php:64
Tools\Context\$ip
$ip
Definition: Context.php:71

static getContext | ( |  | ) |

static

Returns
  context Get the last Context instance

Definition at line 164 of file Context.php.

{
return self::$instance;
}

isTestingEnvironment | ( |  | ) |

Check if executed from phpUnit

Definition at line 155 of file Context.php.

{
return isset($this->server["phpUnit"]) && $this->server["phpUnit"] == true;
}

run | ( |  | ) |

Execute controller

Definition at line 129 of file Context.php.

{
$this->controller->start();
}

serve | ( |  | ) |

Definition at line 101 of file Context.php.

{
// @codeCoverageIgnoreStart
if (!\Entity\ModelBase::init())
{
@require_once(getcwd().'/core/setup/index.php');
die;
}
// @codeCoverageIgnoreEnd
$this->router->init($this->server);
$this->moduleManager = new ModuleManager($this);
$this->hookManager->trigger("routerSetup");
try
{
$this->controller = $this->router->serveUrl();
if (!$this->controller)
throw new \Exception\Error404();
}
catch (\Exception\Error404 $e)
{
$this->controller = new \Controller\Error404($this, array());
}
return $this->controller;
}
Entity
Definition: Address.php:3
Exception
Definition: Error404.php:3
Tools\Context\$controller
$controller
Definition: Context.php:64

## Field Documentation

Tools Cart $cart

private

TODO

/core/tools/Cart.php Not defined yet Can be accessed read-only via $instance->cart

Definition at line 49 of file Context.php.

Tools AController $controller

private

/core/tools/AController.php Controller being called by user's request

Definition at line 64 of file Context.php.

Tools Hooks $hookManager

private

/core/tools/Hooks.php allow triggering hooks and registers module's endpoints Can be accessed read-only via $instance->hookManager

Definition at line 18 of file Context.php.

$instance

staticprivate

Definition at line 23 of file Context.php.

string $ip

private

Contains the remote client's IP, or empty Can be accessed via ->ip

Definition at line 71 of file Context.php.

Tools ModuleManager $moduleManager

private

/core/tools/ModuleManager.php load all active modules and contains informations about them Can be accessed read-only via $instance->moduleManager

Definition at line 31 of file Context.php.

Tools Router $router

private

/core/tools/Router.php Contains information about directories and paths Allow user to generate links Can be accessed read-only via $instance->router

Definition at line 40 of file Context.php.

array $server

private

contains $_SERVER or Unit test environment

Definition at line 77 of file Context.php.

Tools User $user

private

TODO

/core/tools/User.php Can be accessed read-only via $instance->user

Definition at line 57 of file Context.php.

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

- core/tools/Context.php