1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Magium\Util\Configuration; |
4
|
|
|
|
5
|
|
|
abstract class AbstractConfigurationReader |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
protected function introspectClass(ConfigurableObjectInterface $object) |
9
|
|
|
{ |
10
|
|
|
$originalReflectionClass = $reflectionClass = new \ReflectionClass($object); |
11
|
|
|
$classes = [ |
12
|
|
|
$reflectionClass->getName() |
|
|
|
|
13
|
|
|
]; |
14
|
|
|
while (($class = $reflectionClass->getParentClass()) !== false) { |
15
|
|
|
$classes[] = $class->getName(); |
16
|
|
|
foreach ($class->getInterfaceNames() as $interface) { |
17
|
|
|
$reflectionInterface = new \ReflectionClass($interface); |
18
|
|
|
$interfaces = $reflectionInterface->getInterfaceNames(); |
19
|
|
|
$classes = array_merge($interfaces, $classes); |
20
|
|
|
} |
21
|
|
|
$reflectionClass = $class; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
foreach ($originalReflectionClass->getInterfaceNames() as $name){ |
25
|
|
|
$interfaces[] = $name; |
|
|
|
|
26
|
|
|
$reflectionInterface = new \ReflectionClass($name); |
27
|
|
|
$theseInterfaces = $reflectionInterface->getInterfaceNames(); |
28
|
|
|
$theseInterfaces = array_reverse($theseInterfaces); |
29
|
|
|
|
30
|
|
|
$interfaces = array_merge($theseInterfaces, $interfaces); |
31
|
|
|
$classes = array_merge($classes, $interfaces); |
32
|
|
|
} |
33
|
|
|
$classes = array_unique($classes); |
34
|
|
|
$classes = array_reverse($classes); |
35
|
|
|
return $classes; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
protected function recursivelyIntrospectInterface($interfaceName) |
39
|
|
|
{ |
40
|
|
|
$allInterfaces = []; |
41
|
|
|
$reflectionInterface = new \ReflectionClass($interfaceName); |
42
|
|
|
$interfaces = $reflectionInterface->getInterfaces(); |
43
|
|
|
foreach ($interfaces as $interface) { |
44
|
|
|
$interfaceList = $this->recursivelyIntrospectInterface($interface); |
45
|
|
|
$allInterfaces = array_merge($allInterfaces, $interfaceList); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
while (($parentInterface = $reflectionInterface->getParentClass()) != false) { |
49
|
|
|
$allInterfaces[] = $parentInterface->getName(); |
50
|
|
|
$interfaceList = $this->recursivelyIntrospectInterface($parentInterface->getName()); |
51
|
|
|
$allInterfaces = array_merge($allInterfaces, $interfaceList); |
52
|
|
|
$reflectionInterface = $parentInterface; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $allInterfaces; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
abstract public function configure(ConfigurableObjectInterface $object); |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|