Skip to content

Commit

Permalink
Explicitly set FileWriterGeneratorStrategy (#412)
Browse files Browse the repository at this point in the history
* Explicitly set FileWriterGeneratorStrategy

It defaults to the EvaluatingGeneratorStrategy

* Explicitly use EvaluatingGeneratorStrategy when not writing proxies

* Allow ProxyManager ~2.0 to be used
  • Loading branch information
holtkamp authored and mnapoli committed May 29, 2016
1 parent ad0c4e0 commit dd22e25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/lazy-injection.md
Expand Up @@ -86,7 +86,7 @@ Lazy injection requires the [Ocramius/ProxyManager](https://github.com/Ocramius/
{
"require": {
"php-di/php-di": "*",
"ocramius/proxy-manager": "~1.0"
"ocramius/proxy-manager": "~1.0 | ~2.0"
}
}
```
Expand Down
3 changes: 3 additions & 0 deletions src/DI/Proxy/ProxyFactory.php
Expand Up @@ -4,7 +4,9 @@

use ProxyManager\Configuration;
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use ProxyManager\FileLocator\FileLocator;
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
use ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy;

/**
* Creates proxy classes.
Expand Down Expand Up @@ -71,6 +73,7 @@ private function createProxyManager()

if ($this->writeProxiesToFile) {
$config->setProxiesTargetDir($this->proxyDirectory);
$config->setGeneratorStrategy(new FileWriterGeneratorStrategy(new FileLocator($this->proxyDirectory)));
spl_autoload_register($config->getProxyAutoloader());
} else {
$config->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
Expand Down

0 comments on commit dd22e25

Please sign in to comment.