Reputation: 1333
I have a variable like
$shop_id = Configure::read('Settings.SHOP_ID');
which I want to make available to all the Controllers, which are extended from AppController.
What will be the best way to do so?
Upvotes: 0
Views: 41
Reputation: 13534
Just define it in the app/Controller/AppController.php
inside beforFilter callback as follows:
function beforeFilter(){
public var $shop_id = '';
parent::beforeFilter();
$this->shop_id = Configure::read('Settings.SHOP_ID');
}
So in any of your controller's actions it will be accessible as $this->shop_id
Upvotes: 1