Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nilsenpaul opened this issue Feb 5, 2018 · 1 comment
Open

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

nilsenpaul opened this issue Feb 5, 2018 · 1 comment

Comments

@nilsenpaul
Copy link

$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?

@amnah
Copy link
Owner

amnah commented Feb 6, 2018

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");
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants