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

Added ModelRewriteInheritanceVisitor to rewrite the model inheritance for command gen:model. #1328

Merged
merged 7 commits into from
Feb 12, 2020

Conversation

kakuilan
Copy link
Contributor

@kakuilan kakuilan commented Feb 4, 2020

修复命令行创建模型,当模型类已存在时,重新指定uses继承其他父类,而该模型没有更新新父类的问题

#
php bin/hyperf.php --uses="App\Model\Model" gen:model test

@limingxinleo
Copy link
Member

你要不先测试一下看看。。。

我感觉如果你模型里写了些新方法,这么修改,会导致新方法被覆盖

@limingxinleo limingxinleo added the reviewing Reviewing a pull request label Feb 4, 2020
@kakuilan
Copy link
Contributor Author

kakuilan commented Feb 4, 2020

你要不先测试一下看看。。。

我感觉如果你模型里写了些新方法,这么修改,会导致新方法被覆盖

嗯,这个是需要考虑,我再看看

@kakuilan
Copy link
Contributor Author

kakuilan commented Feb 5, 2020

你要不先测试一下看看。。。

我感觉如果你模型里写了些新方法,这么修改,会导致新方法被覆盖

已更新代码,并已测试

php bin/hyperf.php --path=app/Model --uses="App\Model\Model" --inheritance=Model gen:model test
php bin/hyperf.php --path=app/Model --uses="App\Model\Model as TestModel" --inheritance=TestModel gen:model test
php bin/hyperf.php --path=app/Model --uses="App\Model\MyModel" --inheritance=MyModel gen:model test

@limingxinleo
Copy link
Member

return [
    'default' => [
        // ...
        'commands' => [
            'gen:model' => [
                // ...
                'visitors' => [
                    Hyperf\Database\Commands\Ast\ModelRewriteInheritanceVisitor::class,
                ],
            ],
        ],
    ],
]

@kakuilan 你拉一下代码,然后把这个 Visitor 配置加上,再测试一下你的这几种情况,看看是否可以重写父类

@limingxinleo limingxinleo changed the title fix 修复命令行创建模型,当模型类已存在时,重新指定uses继承其他父类,而该模型没有更新新父类的问题 Added ModelRewriteInheritanceVisitor to rewrite the model inheritance for command gen:model. Feb 11, 2020
@huangzhhui
Copy link
Member

这个 changelog 怎么覆盖了?

@limingxinleo
Copy link
Member

limingxinleo commented Feb 11, 2020 via email

@limingxinleo limingxinleo merged commit 6daca6b into hyperf:master Feb 12, 2020
@kakuilan
Copy link
Contributor Author

@limingxinleo 测试没有问题,感谢优化代码

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

Successfully merging this pull request may close these issues.

None yet

3 participants