Yii Framework Forum: how to perfom a task before the current action is called? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

how to perfom a task before the current action is called? Rate Topic: -----

#1 User is offline   me23 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 20-October 08
  • Location:Germany

Posted 28 November 2008 - 04:59 AM

Hello,

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
me23
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,895
  • Joined: 04-October 08
  • Location:DC, USA

Posted 28 November 2008 - 06:57 AM

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.
0

#3 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 28 November 2008 - 09:21 AM

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 :)

nz
0

#4 User is offline   me23 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 20-October 08
  • Location:Germany

Posted 28 November 2008 - 11:46 AM

Thank you for your replies.

I extended CHttpRequest and it works like a charm.

Thanks a lot.
me23
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users