Skip to content

use service locator for configured client strategy #185

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

Merged
merged 1 commit into from
Jul 13, 2017
Merged

use service locator for configured client strategy #185

merged 1 commit into from
Jul 13, 2017

Conversation

fbourigault
Copy link
Contributor

Q A
Bug fix? no
New feature? yes?
BC breaks? no
Deprecations? no
Related tickets partially #109
Documentation n/a
License MIT

What's in this PR?

When available (Symfony 3.3+), a ServiceLocator is used in the ConfiguredClientStrategy to lazy load discoverable clients. A fallback injecting the Container is implemented for older Symfony versions.

Why?

This is required to solve a chicken/egg problem for #109. This should also improve a few resources usage by only building clients when discovery is called (before discovered clients were built at kernel.request or console.command).

Copy link
Collaborator

@dbu dbu left a comment

Choose a reason for hiding this comment

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

great idea, thanks! sounds like an important improvement.

travis is telling that there is some problem with php 5, can you please check that?

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Good!
When Travis is happy, Im happy.


$this->assertEquals($container->get('httplug.client.acme'), NSA::getProperty($strategy, 'client'));
$this->assertEquals($container->get('httplug.client.acme'), NSA::getProperty($strategy, 'asyncClient'));
$this->assertEquals($container->get('httplug.client.acme'), ConfiguredClientsStrategy::getCandidates(HttpClient::class)[0]['class']());
Copy link
Member

Choose a reason for hiding this comment

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

This is not proper PHP 5 code.

$foo = ConfiguredClientsStrategy::getCandidates(HttpClient::class)[0]['class'];
$foo();

    When available (Symfony 3.3+), a ServiceLocator is used in the
ConfiguredClientStrategy to lazy load discoverable clients. A fallback
injecting the Container is implemented for older Symfony versions.
@fbourigault
Copy link
Contributor Author

Thank you for reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants