Feature #43819
Support lazy dependency injection of properties
100%
Description
<?php
namespace Test;
class SomeDependency {
public function __construct() {
echo "Construct SomeDependency\n";
}
public function foo() {
echo "Foo called\n";
}
}
class LazyProxy_Original {
//
// /**
// * @Flow\Inject(lazy=true)
// * @var \Test\SomeDependency
// */
// protected $someProperty;
public function doSomething() {
for ($i = 0; $i < 4; $i++) {
$this->someDependency->foo();
}
// $this->fooBar->unknown();
}
}
class LazyProxy extends LazyProxy_Original {
public function __construct() {
echo "Construct LazyProxy\n";
}
function __get($name) {
echo "LazyProxy get($name)\n";
switch ($name) {
case 'someDependency':
$object = new SomeDependency();
break;
default:
trigger_error(
'Undefined property via __get(): ' . $name,
E_USER_NOTICE);
return NULL;
}
$this->{$name} = $object;
return $object;
}
}
$lazy = new LazyProxy();
$lazy->doSomething();
?>
Related issues
Updated by Gerrit Code Review almost 8 years ago
- Status changed from New to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 9 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Gerrit Code Review almost 8 years ago
Patch set 10 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18917
Updated by Anonymous almost 8 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ff8608f1c296d7cfe8865e629f6d0cdf07a67e61.
Updated by Gerrit Code Review almost 8 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/19099
Updated by Gerrit Code Review almost 8 years ago
Patch set 1 for branch composer has been pushed to the review server.
It is available at https://review.typo3.org/19362
Updated by Anonymous almost 8 years ago
- Status changed from Under Review to Resolved
Applied in changeset e2b1413afaa02c35d0b65965e2d64ab9cfcdd8cb.