how to perfom a task before the current action is called?


how do i perfom some tasks before the current action is called?

For example i like to purify all User-Inputs from $_POST and $_GET through

CHtmlPurifier right after the Application has started and before the current

action is processed.

Or are there better approaches to achieve this?

Thank you


You can write a filter for this purpose. Or if you want to do it even earlier, you can extend CHttpRequest and override its normalizeRequest() method.

There is also a beforeAction() method you can override, it is called after the filter but before the target action (there is also an afterAction but I doubt you will need that :)


Thank you for your replies.

I extended CHttpRequest and it works like a charm.

Thanks a lot.