How to use a Widget as an Action Provider

Comparing #4 with #5

Revision #5 was created by Maurizio Domba Cerin Maurizio Domba Cerin on Jul 19, 2011, 1:58:48 PM.

grammar fix

Content

##What is an Action Provider Widget? As written on the [API docs](http://www.yiiframework.com/doc/api/1.1/CWidget#actions-detail "actions"): An Action Provider Widget is a widget that has declared several actions by using its '**public static function actions()**'. After, a Controller can easily import all its declared actions on its '**public function actions()**'. ##Step 1: Create the Action Class For the sake of the article we need to creatinge an action named **getData** that is supposed to be shared among the whole project and saved with the name **getData.php** on our **protected/components/actions** folder.

```php
class getData extends CAction{
public function run(){
echo 'HELLO WORLD';
[...]