Integrating CAction with CApplicationComponent

Hi,

I am developing an extension for Yii, and am hoping to gain wisdom from some Yii gurus.

The primary portion of the extension is a CApplicationComponent. The component name (accessible through, for example, Yii::app()->myComponentName) is defined in main.php, with configuration options passed along via main.php, as well.

There is also a separate CAction php script within the extension, which the user would add to their desired controller, within the actions() method.

The issue here is that I would like to cleanly access any configuration options passed from main.php to the CAction, and I am not sure of the best way to approach this.

A few ideas were mentioned, both of which seem quite valid. Both ideas involve creating a method in the CApplicationComponent to grab the configuration options. In one approach, we would pass the config options along when adding the action to the desired controller in actions(). The other would be to use the instance defined in main.php (such as Yii::app()->myComponentName) directly within the CAction. The first seems a bit more ‘correct’ but makes the overall solution a bit less plug-and-play for the end user.

One consideration is that the CAction is simply added to a controller’s Actions, whereas my CApplicationComponent is really a single instance of the component (Yii::app()->myComponentName). In practice, the component will be instantiated only one time, and the action only used in one place, but I am curious about best practices, generally. So, I am wondering if the idea/desire to pass config parameters from the component to the action even makes sense here… Perhaps one of the two recommendations from above are the best that can be achieved here? Maybe I am missing something else? I am quite flexible at this point, if anyone has other approaches, generally or specifically, that could be helpful.

Open to ideas, criticisms, suggestions, etc… Thanks!