This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathYiiDebugComponentProxy.php
118 lines (103 loc) · 3.12 KB
/
YiiDebugComponentProxy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* ProxyComponent class file.
*
* @author Sergey Malyshev <[email protected]>
*/
/**
* ProxyComponent represents an ...
*
* Description of ProxyComponent
*
* @author Sergey Malyshev <[email protected]>
* @version $Id$
* @package
* @since 1.1.7
*/
class YiiDebugComponentProxy extends CComponent
{
private $_instance;
private $_isProxy;
protected $abstract = array();
public function init()
{
}
public function getIsProxy()
{
if (null === $this->_isProxy)
{
$this->_isProxy = (null !== $this->_instance && !($this->_instance instanceof $this));
}
return $this->_isProxy;
}
public function setInstance($value)
{
if (null === $this->_instance && false !== is_object($value))
{
$this->abstract = array_merge($this->abstract, get_object_vars($value));
$this->_instance = $value;
}
}
public function getInstance()
{
return $this->_instance;
}
public function __call($name, $parameters)
{
if (false !== $this->getIsProxy() && false !== method_exists($this->_instance, $name))
{
return call_user_func_array(array($this->_instance, $name), $parameters);
}
return parent::__call($name, $parameters);
}
public function __set($name, $value)
{
$setter='set'.$name;
if (false !== method_exists($this, $setter))
{
return call_user_func_array(array($this, $setter), array($value));
}
else if (false !== property_exists($this, $name))
{
return $this->$name = $value;
}
else if (false !== $this->getIsProxy() && false !== method_exists($this->_instance, $setter))
{
return call_user_func_array(array($this->_instance, $setter), array($value));
}
else if (false !== $this->getIsProxy() && false !== property_exists($this->_instance, $name))
{
return $this->_instance->$name = $value;
}
else if (false === $this->getIsProxy() && false !== array_key_exists ($name, $this->abstract))
{
return $this->abstract[$name] = $value;
}
return parent::__set($name, $value);
}
public function __get($name)
{
$getter='get'.$name;
if (false !== method_exists($this, $getter))
{
return call_user_func(array($this, $getter));
}
else if (false !== property_exists($this, $name))
{
return $this->$name;
}
else if (false !== $this->getIsProxy() && false !== method_exists($this->_instance, $getter))
{
return call_user_func(array($this->_instance, $getter));
}
else if (false !== $this->getIsProxy() && false !== property_exists($this->_instance, $name))
{
return $this->_instance->$name;
}
else if (false === $this->getIsProxy() && false !== array_key_exists ($name, $this->abstract))
{
return $this->abstract[$name];
}
return parent::__get($name);
}
}