Inheritance for an admin section

Hi,

I’m trying to use inheritance to reduce the duplication between config files in a frontend and backend system, as outlined here: http://www.yiiframework.com/wiki/33/ in the last comment.

I have set up the file structure and am trying to inherit the params array from /protected/config/main.php to /protected/backend/config/main.php.

I have done this by using the following code in /protected/backend/config/main.php




'params'=>require(dirname(__FILE__).'/params.php'),



And then inserting the file /protected/backend/config/params.php

My question is - how can I inherit the params array given in /protected/config/main.php to /protected/backend/config/params.php? I’ve tried various bits of code but just get a load of errors every time.

Thanks,

G

I use the same approach

Here is my code

frontend and backend config


$base = require_once dirname(__FILE__).DS.'..'.DS.'..'.DS.'common'.DS.'config'.DS.'main.php';


$local=array(

'basePath'=>Yii::getPathOfAlias('frontend'),

..

);


return CMap::mergeArray($base,$local);

common config




// Define root alias path

Yii::setPathOfAlias('site', realpath(dirname(__FILE__).DS.'..'.DS.'..'));

// Standard aliasses

Yii::setPathOfAlias('common',Yii::getPathOfAlias('site').DS.'common');

Yii::setPathOfAlias('console',Yii::getPathOfAlias('site').DS.'console');

Yii::setPathOfAlias('frontend',Yii::getPathOfAlias('site').DS.'frontend');

Yii::setPathOfAlias('backend',Yii::getPathOfAlias('site').DS.'backend');


return array(

...

'extensionPath'=>Yii::getPathOfAlias('common.extensions'),

...

);



note: DS stands for DIRECTORY_SEPARATOR

Ah brilliant - thanks Gustavo! :)