You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
376 B
22 lines
376 B
5 years ago
|
<?php
|
||
|
|
||
|
$obj = new class () extends \yii\base\Component
|
||
|
{
|
||
|
public $foo = 0;
|
||
|
};
|
||
|
|
||
|
$obj->attachBehavior('bar', (new class () extends \yii\base\Behavior
|
||
|
{
|
||
|
public function events()
|
||
|
{
|
||
|
return [
|
||
|
'barEventOnce' => function ($event) {
|
||
|
$this->owner->foo++;
|
||
|
$this->detach();
|
||
|
},
|
||
|
];
|
||
|
}
|
||
|
}));
|
||
|
|
||
|
return $obj;
|