I
I
Ilya Beloborodov2017-06-06 14:49:14
Yii
Ilya Beloborodov, 2017-06-06 14:49:14

Why does behavior() return an empty array?

There is a model inherited by yii\db\ActiveRecord
in the model there is a method

public function behaviors()
    {
        return [
            'loggerBehavior' => [
                'class' => LoggerBehavior::className(),
                'create' => true,
                'update' => true,
                'delete' => true,

            ],
            'mlBehavior' => [
                'class' => MultiLanguageBehavior::className(),
                'mlConfig' => [
                    'db_table' => 'translations_with_string',
                    'attributes' => ['text', 'title', 'image_url', 'image_alt', 'input_name'],
                    'admin_routes' => [
                        'admin/*'
                    ]
                ],
            ],
        ];
    }

when calling $model->behavior() returns an empty array. in similar models everything is fine. for half a day I can’t understand what’s the matter
, and if you call $model->rules(), then the expected array with rules is returned
, and phpstorm sees behaviors() and, when clicked, goes to it,
apparently when $model->behaviors() is called, it displays empty array \yii\base\Component::behaviors(). Why?? I have redefined

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Beloborodov, 2017-06-06
@kowap

In short, I renamed the model and everything worked. I have no idea how it is related.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question