The Use Of The Array Of Event Handlers

Now it is not possible to attach several event handlers.

I try to set one event handler in config file and it is ok:




array(

	'on beforeRequest'=>'foo1',

)



But if I try to set several event handlers it is not ok:




array(

	'on beforeRequest'=>array('foo1', 'foo2'), //It is incorrect

)

The problem is in the yii\base\Component::__set() method.





		} elseif (strncmp($name, 'on ', 3) === 0) {

			// on event: attach event handler

			$this->on(trim(substr($name, 3)), $value);

			return;

		} elseif (strncmp($name, 'as ', 3) === 0) {




I propose to set the check of $value property. If $value is array then it is needed to use the new method named yii\base\Component::onAr(), for example.


public function onAr($name, $handlerArray, $data=null)

{

	foreach ($handlerArray as $value)

	{

		$this->on($name, $value, $data);

	}

}