-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Allow a service to be passed as DSN #46562
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
Conversation
...e/FrameworkBundle/DependencyInjection/Compiler/ReplaceLockStoreDsnByActualDefinitionPass.php
Outdated
Show resolved
Hide resolved
Also, Any idea what's up w/ Tests? Looks like its some postgress issue unrelated to my work. |
So this does not get lost.... How does my username get attached as a contributor? I signed up for symfony community with my email address... what do I need to do to link my username? |
$storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class); | ||
$storeDefinition->setFactory([StoreFactory::class, 'createStore']); | ||
$storeDefinition->setArguments([$resourceStore]); | ||
$storeDefinition->setArguments([$storeDsn]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna assume this was a bug up front.... We were processing env vars but never passing the processed output into store factory. Fixed that as part of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was not a bug, arguments should get the unresolved DSN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. StoreFactory supports passing in quite a few types, but there's no way to reference anything, the current config is limited to passing a string.
The best I've come up with is a compiler pass or redefining the service definitions for lock. Can we figure out a way to pass a reference too?
Also. Is there a more standardized way to do the @ -> service conversion? I've seen examples like this elsewhere, but feels like this conversion could be standardized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be unexpected to me. We don't use such syntax nor feature anywhere else.
Let's find a more boring way if this is really needed.
Should be for 6.2 btw.
$storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class); | ||
$storeDefinition->setFactory([StoreFactory::class, 'createStore']); | ||
$storeDefinition->setArguments([$resourceStore]); | ||
$storeDefinition->setArguments([$storeDsn]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was not a bug, arguments should get the unresolved DSN
I believe if not mistaken that service arguments in yaml use the @sum.service convention. @nicolas-grekas If you can propose a solution I'll get it implemented. |
Syntax used during service definition lock.deployment.store:
class: Symfony\Component\Lock\Store\PdoStore
arguments:
$connOrDsn: '@doctrine.dbal.default_connection' |
Let's close as I feel like this is a niche need. Redefining the service as you did is fine for such use cases. |
Add a compiler pass so that you can reuse the existing doctrine connection when configuring Symfony Lock
lock.yaml: