我想基于这些页面向所有教义表添加前缀: docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/sql -table-prefixes.html和 stackoverflow.com/questions/7504073/how-to-setup-table-prefix-in-symfony2Symfony依赖注入修改服务参数
我也使用依赖注入来使用前缀定义的配置。 symfony.com/doc/current/service_container/definitions.html和symfony.com/doc/current/bundles/configuration.html
不幸的是我不能使用配置中定义的值作为前缀表。 但是,当我手动更改服务定义中的参数值时,它正在工作。
我的项目在这里举行:https://github.com/GrenobleSwing/API
查看文件:
- 的src/GS/ApiBundle /资源/配置/ services.yml
- 的src/GS/ApiBundle/EventSubscriber/TablePrefixSubscriber。 PHP
- SRC/GS/ApiBundle/DependencyInjection /的configuration.php
- SRC/GS/ApiBundle/DependencyInjection/GSApiExtension.php
在此先感谢您的帮助。
朱利安
认为你错过了 'gs_api'这里的根名:https://github.com/GrenobleSwing/API/blob/master/src/GS/ApiBundle/DependencyInjection/GSApiExtension.php#L29。如果不是,'$ config'中有什么? –
嗨,$ config包含配置。 var_dump($ config ['doctrine_table_prefix'])给出了前缀的期望值。 –
此外,当我尝试在依赖注入($ def-> replaceArgument(0,'something_');)中硬编码前缀时,它不起作用。 –