I have extended CWebApplication as following to add params (Application-level parameters) from database. but as of now, i dont get anything when i try to retrieve params using
echo Yii::app()->params[‘adminMobileNo’];
extended code,
class QelasyApplication extends CWebApplication
{
const PARAM_CACHE = 'params';
public function setParams($value)
{
echo 'test 1';
exit;
$params = parent::getParams();
print_r($params);
echo 'test 2';
exit;
$value = Yii::app()->cache->get(self::PARAM_CACHE);
if ($value === false) {
$model = new SystemParam();
$value = $model->getParam();
print_r($value);
echo 'test 3';
exit;
Yii::app()->cache->add(self::PARAM_CACHE, $value, 1800);
}
foreach ($value as $k => $v)
$params->add($k, $v);
}
}
in the main index.php
require_once($yii);
require_once($protected.'components/QelasyApplication.php');
$application = new QelasyApplication($config);
$application->run();
and in a controller, i am trying to access the params as
Yii::app()->params['abc'] = 123;
echo Yii::app()->params['basePath'];
echo Yii::app()->params['abc'];
echo Yii::app()->params['adminMobileNo'];
// print_r(Yii::app()->getParams());
exit;
but no output it just exits.
even the setParams method isnt running, coz the echo statements inside are not displayed. what could be the reason ?