Difference between #4 and #7 of
Behaviors & events

Changes

Title unchanged

Behaviors & events

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

Content changed

[...]
For example, [enabling gzip](http://www.yiiframework.com/doc/cookbook/39/) compression on the output could be done via extending CWebApplication. But because there are entry points for event handlers, one can do this:


```php
Yii::app()->on
bBeginRequest = create_function('$event', 'return ob_start("ob_gzhandler");'), Yii::app()->oneEndRequest = create_function('$event', 'return ob_end_flush();'),
```
[...]
In an OO language like Ruby, it's quite possible to start with an completely empty object and simply build its behavior as you go along. Yii provides this behavior with a little magic. The key is that the class you wish to add the behavior from must extend Cbehavior.
[...]
So, in this case, you are extending the functionality of an object with functionality of another object.

After studying this cookbook page
it isyou are encouraged to reread the [corresponding guide page](http://www.yiiframework.com/doc/guide/basics.component) as it contains advanced information (for example, if you are familiar with interfaces, you might find it enough to implement IBehavior before extending CBehavior).
 
 
- Russian version: [Поведение и события](http://phptime.ru/blog/yii/31.html)
43 0
48 followers
Viewed: 162 088 times
Version: 1.1
Category: Tutorials
Tags:
Written by: pestaa
Last updated by: Gismo
Created on: Aug 24, 2009
Last updated: 11 years ago
Update Article

Revisions

View all history