在 Symfony 插件 sfDoctrineGuardPlugin 中使用自定义表名称?
我正在尝试在我的 Symfony 1.4 项目中使用 sfDoctrineGuardPlugin 。该插件包含一个 schema.yml 文件,用于定义涉及的所有表。表名称采用以下形式:sf_guard_user、sf_guard_user_group、sf_guard_user_permission 等。我宁愿将这些表命名为:users、user_groups、user_permissions 等。有没有办法让我在不直接编辑插件代码的情况下执行此操作?
I'm attempting to use the sfDoctrineGuardPlugin in my Symfony 1.4 project. This plugin includes a schema.yml file, which is used to define all the tables involved. The table names take on the form of: sf_guard_user, sf_guard_user_group, sf_guard_user_permission, etc. I'd rather have these tables be named: users, user_groups, user_permissions, etc. Is there a way for me to do this without editing the plugin code directly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
覆盖项目架构文件中的这些内容:
此外,我更愿意将它们移至单独的文件中,例如
sfDoctinePlugin-schema.yml
。希望有帮助。
Override those things in your project's schema files:
Also, I'd prefer to move them into separate file, say
sfDoctinePlugin-schema.yml
.Hope that helps.
这不是一个好的做法,我不鼓励您这样做。
话虽如此(并且加粗,哈哈),您应该能够将包含的架构复制到项目级别架构中并添加
tableName
每个记录定义的键。我知道以这种方式修改架构一般来说是有效的,因为我定期向 sfGuardUser 添加额外的列,而不是使用完整的配置文件类...我认为修改表名称会起作用以及。在构建数据库后,您应该看到您的表名称。问题是,如果在实际的插件代码中存在有人对表名称进行硬编码而不是使用模型中定义的别名的情况,那么事情可能无法正常工作。我不知道是否存在这样的情况,但您应该在继续该项目之前进行彻底的测试。
Thats not a good practice, and i would discourage you from doing it.
With that said (and bolded, haha) you should be able to copy the included schema into your project level schema and add the
tableName
key to each record definition. I know that modify the schema in this way works generally speaking because i do it regularly to add extra columns tosfGuardUser
instead of using a full blown profile class... i assume that modifying the table name would work as well.That should after building the db you should see your table names. The thing is if there are cases in the actual plugin code where someone has hard coded the table name instead of using the alias defined in the model things may not work. I dont know that there are any situations like this, but you should test thoroughly before moving on with the project.