tbreuss / yii2-inertia

The Yii 2 server-side adapter for Inertia.js.
MIT License
62 stars 9 forks source link

Enhancement: parent::beforeAction in docs #3

Closed SOHELAHMED7 closed 4 years ago

SOHELAHMED7 commented 4 years ago

In docs (readme.md file), -> "Shared data" section

    public function beforeAction()
    {
        $shared = [
            'user' => $this->getUser(),
            'flash' => $this->getFlashMessages(),
            'errors' => $this->getFormErrors()
        ];
        Yii::$app->get('inertia')->share($shared);
        return true;
    }

parent::beforeAction($action) statement is not present. It is nice to have there.

So last line of that method should be

return parent::beforeAction($action);

    public function beforeAction()
    {
        $shared = [
            'user' => $this->getUser(),
            'flash' => $this->getFlashMessages(),
            'errors' => $this->getFormErrors()
        ];
        Yii::$app->get('inertia')->share($shared);
        return parent::beforeAction($action);
    }

If you are fine with above proposal, I can also help with Pull Request.

tbreuss commented 4 years ago

Good catch! Thank you.

It would be nice to get a pull request.

Do you find some time to do so?

tbreuss commented 4 years ago

Fixed with bf327d3783b6fd71e4ecb5a057f414ba40b88526. Thanks for reporting.