2amigos/yii2-usuario

Bug fix for extending views

Closed this issue · 6 comments

file: Da\User\Bootstrap.php
line 292:

protected function initControllerNamespace(WebApplication $app)
    {
        $app->getModule('user')->controllerNamespace = $app->getModule('user')->controllerNamespace;
        $app->getModule('user')->setViewPath('@Da/User/resources/views');
    }

change to:

protected function initControllerNamespace(WebApplication $app)
    {
        $app->getModule('user')->controllerNamespace = $app->getModule('user')->controllerNamespace;

        if (!empty($app->getModule('user')->viewPath)){
            $app->getModule('user')->setViewPath($app->getModule('user')->viewPath);
        }else{
            $app->getModule('user')->setViewPath('@Da/User/resources/views');
        }
    }

Is the if really required? The viewPath property is correctly initialized in the module, should work with just the first command, isn't it?

If you think it is not necessary, you can remove it.

I was wondering if you added it on purpose or for precaution. It shouldn't be necessary so I was asking if you tested it

I haven't test it.
I think it's better to prevent someone leaving empty.

Test it already.

protected function initControllerNamespace(WebApplication $app)
    {
        $app->getModule('user')->controllerNamespace = $app->getModule('user')->controllerNamespace;
        $app->getModule('user')->setViewPath($app->getModule('user')->viewPath);
    }

If you don't mind creating a PR I'll merge right away. Thanks