-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Lazy services - service proxies #7527
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f503ad8
First implementation of lazy services via proxy manager
Ocramius 67aef45
Adding basic logic to generate proxy instantiation into a php dumped …
Ocramius f4a19c7
Compiling proxies into the generated DIC file
Ocramius d2760f1
Upgrading dependency to ProxyManager 0.3.*
Ocramius 4a13f82
Suggesting ProxyManager in composer.json, removing useless calls
Ocramius a6a6572
Adding failing test to demonstrate that proxy initialization breaks s…
Ocramius 35fdded
Fixing shared service instance
8000
Ocramius bec7774
Sharing services in the container should only happen when proxying fa…
Ocramius 468e92e
Adding tests for proxy sharing within dumped containers
Ocramius 4ecd5ad
Fixing shared proxies into the container
Ocramius 11a1da9
Bumping required version of ProxyManager
Ocramius 5870fed
Docblock for ContainerBuilder#shareService
Ocramius 695e3c5
Adding `ContainerBuilder#addClassResource`
Ocramius c5a5af0
Adding test to check that class resources are registered for lazy ser…
Ocramius 29899ec
Fixing tests, registering class resources for lazy services
Ocramius b5d0298
Reverting import of global namespace classes
Ocramius cda390b
Lazier checks on the proxy structure (avoiding whitespace-based test …
Ocramius 1eb4cf7
Getters for proxied services are public for 5.3.3 compatibility
Ocramius b417969
Enforcing soft dependency to ProxyManager
Ocramius 1e24767
Reverting documentation changes, adding exception types description i…
Ocramius 450635a
Lazier checks on the proxy structure
Ocramius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adding basic logic to generate proxy instantiation into a php dumped …
…container
- Loading branch information
commit 67aef456ba5c7d4a2e8ba6b1170d9f6e1cfde25e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_service.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Container; | ||
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; | ||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
use Symfony\Component\DependencyInjection\Exception\RuntimeException; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\DependencyInjection\Parameter; | ||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; | ||
|
||
/** | ||
* ProjectServiceContainer | ||
* | ||
* This class has been auto-generated | ||
* by the Symfony Dependency Injection Component. | ||
*/ | ||
class ProjectServiceContainer extends Container | ||
{ | ||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->services = | ||
$this->scopedServices = | ||
$this->scopeStacks = array(); | ||
|
||
$this->set('service_container', $this); | ||
|
||
$this->scopes = array(); | ||
$this->scopeChildren = array(); | ||
} | ||
|
||
/** | ||
* Gets the 'foo' service. | ||
* | ||
* This service is shared. | ||
* This method always returns the same instance of the service. | ||
* | ||
* @param boolean $lazyLoad whether to try lazy-loading the service with a proxy | ||
* | ||
* @return stdClass A stdClass instance. | ||
*/ | ||
protected function getFooService($lazyLoad = true) | ||
{ | ||
if ($lazyLoad) { | ||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory(new \ProxyManager\Configuration()); | ||
$container = $this; | ||
|
||
return $factory->createProxy( | ||
'stdClass', | ||
function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { | ||
$proxy->setProxyInitializer(null); | ||
|
||
$wrappedInstance = $container->getFooService(false); | ||
|
||
return true; | ||
} | ||
); | ||
} | ||
|
||
return $this->services['foo'] = new \stdClass(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you should not put
@todo
on the second line. It makes it quite hard to read (I first thought it was a second TODO)