Doctrine 生成的模型可以有前缀吗?

发布于 2024-07-22 22:23:10 字数 363 浏览 3 评论 0原文

Doctrine 中是否有一个选项可以为 Doctrine 生成的任何类指定前缀?

我在使用新的 Zend 自动加载器和自动加载模型时遇到了问题,自动加载器学说也没有帮助。

理想情况下,我应该让该学说生成的类以“Model_”为前缀,如“Model_User”中所示。

我在尝试使用generate-migrations-diff生成迁移时遇到了这个问题,它说 Fatal error: Cannot redeclare class BaseUser in /tmp/fromprfx_doctrine_tmp_dirs/ generated/BaseUser.php on line 38

因为实际模型是在新生成的模型之前加载的班级。

Is there an option in Doctrine that would specify a prefix for any classes generated by doctrine?

I'm having trouble with the new Zend autoloader and autoloading models, the doctrine autoloader doesn't help either.

Ideally I'd have the doctrine generated classes prefixed with 'Model_', as in 'Model_User'.

I ran into this issue while trying to generate migrations using generate-migrations-diff, it says Fatal error: Cannot redeclare class BaseUser in /tmp/fromprfx_doctrine_tmp_dirs/generated/BaseUser.php on line 38

Because the actual model is loaded before the newly generated class.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洛阳烟雨空心柳 2024-07-29 22:23:10

抱歉,我太仓促了,几秒钟后就找到了答案。

补充:

Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative');

修复了问题。

Sorry, I was to hasty about asking the question and found the answer seconds later.

Adding:

Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative');

Fixed the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文