0
votes

I'm trying to add a prefix to all the doctrine tables based on these pages: docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/sql-table-prefixes.html and stackoverflow.com/questions/7504073/how-to-setup-table-prefix-in-symfony2

I'm also using dependency injection to use the configuration for the prefix definition. symfony.com/doc/current/service_container/definitions.html and symfony.com/doc/current/bundles/configuration.html

Unfortunatly I'm not able to have the tables prefixed using the value defined in the configuration. But when I manually change the value of the argument in the service definition, it is working.

My project is hosted here: https://github.com/GrenobleSwing/API

See files:

  • src/GS/ApiBundle/Resources/config/services.yml
  • src/GS/ApiBundle/EventSubscriber/TablePrefixSubscriber.php
  • src/GS/ApiBundle/DependencyInjection/Configuration.php
  • src/GS/ApiBundle/DependencyInjection/GSApiExtension.php

Thanks in advance for your help.

Julien

1
Think you missed gs_api root name here: github.com/GrenobleSwing/API/blob/master/src/GS/ApiBundle/…. If not, what's in $config?Mateusz Sip
Hi, $config contains the configuration. var_dump($config['doctrine_table_prefix']) is giving the expected value for the prefix.Julien Billoudet
Also, when I try to hard code the prefix in the dependency injection ($def->replaceArgument(0, 'something_');), it is not working.Julien Billoudet

1 Answers

0
votes

I cloned your repository, run app in containers and found out what's wrong.

Remove that line.

Why?

Now it loads the same configuration twice, and the one loaded in config was used to register event subscribers for Doctrine. So your modifications inside GSApiExtension were omitted.

Checked by myself, and it works now.