yiisoft/yii2 — pull request #1212 by egorpromo (2013-11-17 03:53:37+00:00)
Title: Events can be used like filters

Is it possible to introlduce in Yii2 not simple Events only but Filters?

The defference is that the Event does things only, but Filter can be used for modification of variables. So we do something like:
```php
$myEvent = new myEvent;
$myEvent->var=$variable; //we have $var and want modify it
$event = $this->trigger('myfilter', $myEvent);
//Now we have modified $event and modified $event->var inside
$variable = $event->var;
```
So it is possible to modify variables using Events system. It is like [wordpress filters](http://codex.wordpress.org/Function_Reference/add_filter).

Filters can be used in core Yii2. Suppose we have Response component and want modify it in [yii\web\Application::handleRequest() method](https://github.com/yiisoft/yii2/blob/master/framework/yii/web/Application.php#L63)
Instead simple `return $response;` we can do something like:
```php
$event = $this->trigger('responseModification', $response);
return $event->data; //In $event->data we have new $responce which have been modified on Event
```