Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Merge 98efa38 into 9418a22
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil committed May 15, 2017
2 parents 9418a22 + 98efa38 commit 21331d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -12,7 +12,8 @@
],
"require": {
"ocramius/proxy-manager": "^2.0",
"nette/di": "^2.4"
"nette/di": "^2.4",
"nette/php-generator": "^2.6|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.6",
Expand Down
6 changes: 3 additions & 3 deletions src/DI/ProxyExtension.php
Expand Up @@ -9,7 +9,7 @@
use Nette\DI\Helpers;
use Nette\DI\Statement;
use Nette\PhpGenerator\ClassType;
use Nette\PhpGenerator\Method;
use Nette\PhpGenerator\Closure;
use Nette\Utils\Validators;
use ProxyManager\Configuration;
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
Expand Down Expand Up @@ -116,8 +116,8 @@ public function afterCompile(ClassType $class)
// modify original method body to return proxy instead
$method = $class->getMethod(Container::getMethodName($name));
$method->setBody(sprintf(
"return \$this->getService('%s')->createProxy(\n\t%s::class,\n\tfunction (&\$wrappedObject, \$proxy, \$method, \$parameters, &\$initializer) {\n\t\t\$wrappedObject = (%s)();\n\t\t\$initializer = null;\n\t}\n);",
$this->prefix('lazyLoadingValueHolderFactory'), $type, ltrim(preg_replace('#^#m', "\t\t", (new Method())->addBody($method->getBody())))
"return \$this->getService('%s')->createProxy(\n\t%s::class,\n\tfunction (&\$wrappedObject, \$proxy, \$method, \$parameters, &\$initializer) {\n\t\t\$wrappedObject = (%s)();\n\t\t\$initializer = null;\n\t\treturn true;\n\t}\n);",
$this->prefix('lazyLoadingValueHolderFactory'), $type, ltrim(preg_replace('#^#m', "\t\t", (new Closure())->addBody($method->getBody())))
));
}

Expand Down

0 comments on commit 21331d4

Please sign in to comment.