My app starts on the Pages controlleR; first thing the app needs is to set a config value -from url- that i want to use on the whole app, for example localhost/laborbase/client1 i need to keep 'client1' as a constant.
So in AppController, beforefilter, i assign a constant (tried with Configure:: but same problem: value gets 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);
//Configure::write('CLIENT_URL', $value);
define("CLIENT_URL", $value);
debug('after assign:'.CLIENT_URL); // THIS SHOWS FINE
}
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 a pages action is called (Pages/display
public function display() {
debug(Configure::read('CLIENT_URL')); // IT SHOWS FINE HERE
...
From UsersController, i can't access the value: constant comes undefined
public function clientLogin($id = null) {
$this->autoRender = false;
$this->RequestHandler->setContent('json', 'application/json');
ob_end_clean();
///debug(Configure::read('CLIENT_URL'));
echo json_encode(CLIENT_URL);
}
And is is not available to other controllers. Tried Configuration:: and same thing.
I need to be able to access the config value from anywhere in my app.
Can you help?