2 actions, same content/job


I have an dedicated controller for ajax content (ajaxController) with an lot of actions insight, and also an action called actionReturnTagList()

Now, on an different controller I need the functionality of actionReturnTagList() again.

First idea was to simply address/access the action from the ajaxController, like so: ajaxController::actionReturnTagList()

So there are 2 different problems:

1.) this doesn’t work and

2.) this will not be MVC conform, i think.

In this case, probably, I have to use components for that… <-- is this right?!

So under protected/components i have an globalFunctions.php "component" where i put/collect methods, which I need on different places.

So I also could add this functionality to this component - lets give a new name to this method: createTagList().

Thereafter ajaxController/actionReturnTagList() could look like this:

 public function actionReturnTagList()




The Point is: The functionality of createTagList() is used very rarely in the application.

So the code is loaded and parese all the time, the globalFunctions component is loaded.

Is there an performance (or application overhead)-benefit if I create an new, additional component (like components/rarelyUsedFunctions.php) in order to put the createTagList() functionality in there?

Or is there no different, because the application (probably) loads all the files in …/protected/components/* ? In this case it would be better to put this method insight globalFunctions.php to avouid one more disk I/O.

I’m sure at this case/point there will be not an noticeable performance change, because there are only some lines of code. But, this is also an policy decision for more equal issues like this.

Thank you.

try to create CAction it will simplify controller

Thank you, this is, what i was looking for! :slight_smile: