-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Add support for defining method calls in InlineServiceConfigurator #34916
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
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
Deprecations? | no |
Tickets | |
License | MIT |
Doc PR | N/A |
@@ -23,6 +23,7 @@ class InlineServiceConfigurator extends AbstractConfigurator | |||
use Traits\ArgumentTrait; | |||
use Traits\AutowireTrait; | |||
use Traits\BindTrait; | |||
use Traits\CallTrait; |
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.
we could add also ConfiguratorTrait and PropertyTrait
but please confirm on a real app that this actually works before.
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 tested it in a app powered by Symfony 4.3
before landing this PR and it worked like a charm, even with nested inlines.
For reference, service is defined like this :
$services
->set(EventStoreConnection::class)
->factory([EventStoreConnectionFactory::class, 'createFromConnectionString'])
->args([
'%env(resolve:EVENT_STORE_DSN)%',
inline(ConnectionSettings::class)
->factory([
inline(ConnectionSettingsBuilder::class)
->call('useCustomLogger', [ref(LoggerInterface::class)]),
'build'
])
]);
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.
And I get this :
<?php
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'Prooph\EventStore\Async\EventStoreConnection' shared service.
include_once $this->targetDirs[3].'/vendor/prooph/event-store-client/src/EventStoreConnectionFactory.php';
include_once $this->targetDirs[3].'/vendor/prooph/event-store-client/src/ConnectionSettings.php';
include_once $this->targetDirs[3].'/vendor/prooph/event-store-client/src/ConnectionSettingsBuilder.php';
$a = new \Prooph\EventStoreClient\ConnectionSettingsBuilder();
$a->useCustomLogger(($this->privates['logger'] ?? ($this->privates['logger'] = new \Symfony\Component\HttpKernel\Log\Logger())));
return $this->services['Prooph\\EventStore\\Async\\EventStoreConnection'] = \Prooph\EventStoreClient\EventStoreConnectionFactory::createFromConnectionString($this->getEnv('resolve:EVENT_STORE_DSN'), $a->build());
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.
ok, thanks, can you add ConfiguratorTrait and PropertyTrait please and validate they're ok too?
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.
They are ! PR updated.
Test failure in the |
Can you please add a corresponding line in the CHANGELOG of the component? |
@nicolas-grekas Done. Is the wording okay for you ? |
Thank you @Lctrs. |
…rviceConfigurator (Lctrs) This PR was squashed before being merged into the 5.1-dev branch. Discussion ---------- [DI] Add support for defining method calls in InlineServiceConfigurator | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | N/A Commits ------- 5af6e21 [DI] Add support for defining method calls in InlineServiceConfigurator