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

Fix connection for doctrine event tag #363

Merged

Conversation

wbloszyk
Copy link
Member

@wbloszyk wbloszyk commented Feb 18, 2021

Subject

After #355 I got some errors like:

The Doctrine connection "%simplethings.entityaudit.connection%" referenced   
!!    in service "simplethings_entityaudit.log_revisions_listener" does not exist  
!!    . Available connections names: "default".   

It look like doctrine event tag will not convert parameter name into value. This PR will replace this parameter name into value.

I am targeting this branch, because this change respect BC.

Changelog is not needed becouse we do not release #355 yet.

@wbloszyk
Copy link
Member Author

@phansys
I check in my project and it is working. Anyway I can not fix tests. Can you look at this?

@phansys
Copy link
Member

phansys commented Feb 18, 2021

@phansys
I check in my project and it is working. Anyway I can not fix tests. Can you look at this?

Sure, I'll try to check this later.

@phansys
Copy link
Member

phansys commented Feb 18, 2021

I think this is working, at least in the test environment: wbloszyk#1.
Please, confirm if you can check these changes in a working project.

@wbloszyk
Copy link
Member Author

I think this is working, at least in the test environment: wbloszyk#1.
Please, confirm if you can check these changes in a working project.

@phansys
Parameter will be always the same simplethings.entityaudit.connection. We do not have to check it, becouse it is set in load().

@wbloszyk wbloszyk marked this pull request as ready for review February 20, 2021 09:09
@wbloszyk wbloszyk requested review from phansys and a team February 20, 2021 09:09
@wbloszyk wbloszyk requested review from phansys and a team February 20, 2021 11:44

foreach ($tags as $attributes) {
if (isset($attributes['connection'])) {
$attributes['connection'] = (string) $container->getParameter('simplethings.entityaudit.connection');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, if we harcode the parameter name here, we are making less flexible the replacing mechanism.
If in the future the parameter name used in these tags is renamed, we must replace this occurrence too.
I also think that the final users could not override these services if they need to use a different value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set this simplethings.entityaudit.connection parameter in the same SimpleThingsEntiyAuditExtension, so I think we do not have to afriaid about rename. Additionaly if users override this service then connection name must be set directly, oherwise expection will be throw.

We can also move it to the compiler pass. Then we can check whole services tagged by doctrine.event_listener and replace simplethings.entityaudit.connection parameter in connetion to propertly value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symfony/symfony#40262
WDYT? @sonata-project/contributors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand, should we wait for symfony/symfony#40262 or can we merge this ?

Copy link
Member Author

@wbloszyk wbloszyk Feb 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can merge this now. This code allow use param only for ower services.we can remove this code when symfony accept it and we bump doctrine-bridge.

Also they can accept it as feature and merge it in 5.2 version.

@VincentLanglet VincentLanglet merged commit 3179d40 into sonata-project:1.x Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants