yii2-user icon indicating copy to clipboard operation
yii2-user copied to clipboard

$this->module does not return module, breaks code

Open nilsenpaul opened this issue 7 years ago • 1 comments

$this->module, as used in many classes in the plugin, does not return the module object with my config. Instead, it returns yii\web\Application, causing code to break (controllers/AdminController::findModel, for instance). I have extended several classes to alter default behaviour.

What's wrong in my configuration?

nilsenpaul avatar Feb 05 '18 14:02 nilsenpaul

That's because I set it explicitly in my files. What you need to do is call/set the module yourself using $module = Yii::$app->getModule("user");

For reference:

https://github.com/amnah/yii2-user/blob/master/models/User.php#L74-L87

    /**
     * @var \amnah\yii2\user\Module
     */
    public $module;
    /**
     * @inheritdoc
     */
    public function init()
    {
        if (!$this->module) {
            $this->module = Yii::$app->getModule("user");
        }
    }

amnah avatar Feb 06 '18 00:02 amnah