1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Isolate\LazyObjects\Proxy\Adapter\OcramiusProxyManager\MethodGenerator; |
4
|
|
|
|
5
|
|
|
use ProxyManager\Generator\MethodGenerator; |
6
|
|
|
use ProxyManager\Generator\ParameterGenerator; |
7
|
|
|
use ReflectionClass; |
8
|
|
|
use ReflectionProperty; |
9
|
|
|
use Zend\Code\Generator\PropertyGenerator; |
10
|
|
|
|
11
|
|
|
class Constructor extends MethodGenerator |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Constructor |
15
|
|
|
*/ |
16
|
|
|
public function __construct( |
17
|
|
|
ReflectionClass $originalClass, |
18
|
|
|
PropertyGenerator $wrappedObjectProperty, |
19
|
|
|
PropertyGenerator $lazyPropertiesProperty, |
20
|
|
|
PropertyGenerator $methodReplacementsProperty, |
21
|
|
|
PropertyGenerator $initializerProperty |
22
|
|
|
) { |
23
|
|
|
parent::__construct('__construct'); |
24
|
|
|
|
25
|
|
|
$lazyPropertiesArg = new ParameterGenerator('lazyProperties'); |
26
|
|
|
$lazyPropertiesArg->setDefaultValue([]); |
27
|
|
|
$lazyPropertiesArg->setType('array'); |
28
|
|
|
|
29
|
|
|
$methodReplacementsArg = new ParameterGenerator('methodReplacements'); |
30
|
|
|
$methodReplacementsArg->setDefaultValue([]); |
31
|
|
|
$methodReplacementsArg->setType('array'); |
32
|
|
|
|
33
|
|
|
$this->setParameter(new ParameterGenerator('wrappedObject')); |
34
|
|
|
$this->setParameter($lazyPropertiesArg); |
35
|
|
|
$this->setParameter($methodReplacementsArg); |
36
|
|
|
|
37
|
|
|
$this->setBody( |
38
|
|
|
'$this->' . $wrappedObjectProperty->getName() . " = \$wrappedObject;\n" |
39
|
|
|
. '$this->' . $lazyPropertiesProperty->getName() . " = \$lazyProperties;\n" |
40
|
|
|
. '$this->' . $methodReplacementsProperty->getName() . " = \$methodReplacements;\n" |
41
|
|
|
. '$this->' . $initializerProperty->getName() . " = new \\Isolate\\LazyObjects\\Object\\Property\\Initializer();\n" |
42
|
|
|
. '$this->' . $initializerProperty->getName() . "->initialize(\$this->" . $lazyPropertiesProperty->getName() . ", \"__construct\", \$this->" . $wrappedObjectProperty->getName() . ");\n" |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|