Problem with extension configuration

I'm trying to build an extension, which I would call in one case like this:


and in another case I call an action of the extension for which I need to setup an controllerMap in /protected/config/main.php:


Now I have that the problem that the configurated vars, which I setup in main.php like this:


  'getfile' => array(

    'class'      => 'application.extensions.getfile.GetFile',

    'imageDir' => '/images/',

    'cacheDir'  => '/images/_cache/'



are not available, if I call the actionGetfile. If i setup the controllerMap like this:



    'class'        => 'application.extensions.getfile.GetFile',

    'imageDir'  => '/images/',

    'cacheDir'  => '/images/_cache/'



it works. But now I have defined the vars "imageDir" and "cacheDir" twice, which is not very nice. Is there any solution, to use the vars defined under "components" in an action?

What is your extension? is it a controller or application component?


What is your extension? is it a controller or application component?

it's a controller.

should I make it as application component?

If a controller, your second configuration is needed. Your first configuration is used for an app component.

Whether it is a controller or an app component depends on your need. If your extension needs to interact directly with users (via controller action), then it is a controller. If it is internally used by other code, then it is an app component.

does it mean, that in my case, I need to have the configuration vars in two places?

Yes, if that is your goal. However, I think it is better to make it an app component rather than a controller, unless you have very strong reason that this should be a controller.