A
A
Alexander2016-05-26 17:04:37
Yii
Alexander, 2016-05-26 17:04:37

How to access a class property using behavior in yi2?

Hello! in yii1 it is possible to put a behavior on a class and then access it and its methods as a property, for example
$user->var->method() where var is a behavior,
but in yii2 I haven’t figured out how to do
it right away access the method then everything is ok,
$user->method()
but I need it through the class property

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Gogolinsky, 2016-05-26
@joinex

$component->getBehavior('myBehavior')->foo()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question