Does anyone know how to place configuration stuff for say a controller in the config file. I have this controller i’d like to set paths for in in the configuration file for it to search.
already done this. Also CController is a subclass of CComponent when you drill down. What I wanted to know was what I’m missing in my controller as I really couldt see anything special in other components that we can set stuff from there.
/**
* Loads configuration data from a file and merges it with the existing configuration.
*
* A config file must be a PHP script returning a configuration array (like the following)
* <pre>
* return array
* (
* 'name'=>'My Application',
* 'defaultController'=>'index',
* );
* </pre>
*
* @param string configuration file path (if using relative path, be aware of what is the current path)
* @see mergeWith
*/
public function loadFromFile($configFile)
{
$data=require($configFile);
if($this->getCount()>0)
$this->mergeWith($data);
else
$this->copyFrom($data);
}
I would imagine that if your controller is a module controller, you probably would need to add the path alias for the controller’s config/ folder to your <ModuleName>Module.php file so Yii can find it.
I figured out how to do it though i moved the variable from the controller to my web application class.
The configuration then became:
array(
'appPaths'=>array(<path>)
)
I can then access it by doing
Yii::app()->appPaths;
the params array is nice but sometimes it’s nicer to not have to type the access statment for the params.
I’m also working with a multi file configuration and some configurations are set in the common framework and some are set by the actual application and the common framework uses the settings that are set by the app.