My application runs on the controlleR page; The first thing that applications need is to set the configuration value - from url - which I want to use for the entire application, for example localhost / laborbase / client1, I need to save "client1" as a constant.
So, in AppController, beforefilter, I assign a constant (checked using Configure ::, but with the same problem: the value is lost for other controllers.
Appcontroller
public function beforeFilter() {
$clienturl = explode('/', $_SERVER['REQUEST_URI']);
if (sizeOf($clienturl) == 3) {
$this->__fetchSettings($clienturl[2]);
}
public function __fetchSettings($value) {
debug('from app'.$value);
define("CLIENT_URL", $value);
debug('after assign:'.CLIENT_URL);
}
PagesControler
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('home', 'homedemo');
}
UsersController
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('clientLogin', 'add');
}
and display the value for testing when the page action is called (Pages / Display
public function display() {
debug(Configure::read('CLIENT_URL'));
...
From UserController I cannot access the value: constant comes undefined
public function clientLogin($id = null) {
$this->autoRender = false;
$this->RequestHandler->setContent('json', 'application/json');
ob_end_clean();
echo json_encode(CLIENT_URL);
}
And not available for other controllers. Trial configuration :: and the same.
.
?