public static function on($class, $name, $handler, $data = null, $append = true)
    {
        $class = ltrim($class, '\\');
        if ($append || empty(self::$_events[$name][$class])) {
            self::$_events[$name][$class][] = [$handler, $data];
        } else {
            array_unshift(self::$_events[$name][$class], [$handler, $data]);
        }
    }
public static function on($class, $name, $handler, $data = null, $append = true)
    {
        $class = ltrim($class, '\\');
        if ($append || empty(self::$_events[$name][$class])) {
            self::$_events[$name][$class][] = [$handler, $data];
        } else {
            array_unshift(self::$_events[$name][$class], [$handler, $data]);
        }
    }
public static function on ( $ class , $ name , $ handler , $ data = null , $ append = true ) { $ class = ltrim ( $ class , '\\' ) ; if ( $ append || empty ( self :: $ _events [ $ name ] [ $ class ] ) ) { self :: $ _events [ $ name ] [ $ class ] [ ] = [ $ handler , $ data ] ; } else { array_unshift ( self :: $ _events [ $ name ] [ $ class ] , [ $ handler , $ data ] ) ; } }
Attaches an event handler to a class-level event.

When a class-level event is triggered, event handlers attached
to that class and all parent classes will be invoked.

For example, the following code attaches an event handler to `ActiveRecord`'s
`afterInsert` event:

```php
Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_INSERT, function ($event) {
Yii::trace(get_class($event->sender) . ' is inserted.');
});
```

The handler will be invoked for EVERY successful ActiveRecord insertion.

For more details about how to declare an event handler, please refer to [[Component::on()]].

@param string $class the fully qualified class name to which the event handler needs to attach.
@param string $name the event name.
@param callable $handler the event handler.
@param mixed $data the data to be passed to the event handler when the event is triggered.
When the event handler is invoked, this data can be accessed via [[Event::data]].
@param boolean $append whether to append new event handler to the end of the existing
handler list. If false, the new handler will be inserted at the beginning of the existing
handler list.
@see off()
Attaches an event handler to a class - level event .