PluginProbe
CSS & JavaScript Toolbox / 11.2
CSS & JavaScript Toolbox v11.2
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / installer / reflection.class.php

reflection.class.php in CSS & JavaScript Toolbox 11.2, at framework/installer/reflection.class.php

126 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 /**
7 *
8 */
9 class CJTInstallerReflection {
10
11 /**
12 *
13 */
14 const ROOT_INSTALLER = 'CJTInstaller';
15
16 /**
17 *
18 */
19 const ROOT_UPGRADER = 'CJTUpgrader';
20
21 /**
22 * put your comment there...
23 *
24 * @var mixed
25 */
26 public static $excludeList = array('__construct', '__destruct', 'getInstance');
27
28 /**
29 * put your comment there...
30 *
31 * @var mixed
32 */
33 protected $filters;
34
35 /**
36 * put your comment there...
37 *
38 * @var mixed
39 */
40 protected $installerClass;
41
42 /**
43 * put your comment there...
44 *
45 * @var mixed
46 */
47 protected $operations;
48
49 /**
50 * put your comment there...
51 *
52 * @var mixed
53 */
54 protected $rootClass;
55
56 /**
57 * put your comment there...
58 *
59 * @param mixed $installerClass
60 * @return CJTInstallerReflection
61 */
62 public function __construct($installerClass, $rootClass, $filters) {
63 $this->installerClass = $installerClass;
64 $this->rootClass = $rootClass;
65 $this->filters = $filters;
66 }
67
68 /**
69 * put your comment there...
70 *
71 * @param mixed $installerClass
72 * @param mixed $rootClass
73 * @param mixed $filters
74 */
75 public static function getInstance($installerClass, $rootClass = self::ROOT_INSTALLER, $filters = ReflectionMethod::IS_PUBLIC) {
76 return new CJTInstallerReflection($installerClass, $rootClass, $filters);
77 }
78
79 /**
80 * Get all Non-Static Public methods below $this->rootClass.
81 *
82 * @return array
83 */
84 public function getOperations() {
85 // Load operations if not loaded yet!
86 if ($this->operations === null) {
87 $this->operations = array();
88 // Only get operations from parent classes if Root class is not the target class!
89 if ($this->installerClass != $this->rootClass) {
90 // Get all parent class until $this->rootClass, discard other classes!
91 $parents = array_reverse(array_keys(class_parents($this->installerClass)));
92 $targetClasses = array_slice($parents, array_search($this->rootClass, $parents));;
93 }
94 $targetClasses[] = $this->installerClass;
95 // reflect class methods!
96 $reflection = new ReflectionClass($this->installerClass);
97 foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
98 $methodName = $method->getName();
99 // Get all Public, Non-Static, belong to any of the target Classes and includes in self::$excludeList variable!
100 $static = $method->isStatic();
101 $excluded = in_array($methodName, self::$excludeList);
102 $targeted = in_array($method->getDeclaringClass()->getName(), $targetClasses);
103 if (!$static && !$excluded && $targeted) {
104 $this->operations[$methodName] = array('name' => $methodName);
105 // Read Installer Reflection attributes!
106 if (preg_match_all('/\@CJTInstallerReflection\<([^\>]+)\>/', $method->getDocComment(), $rawAttributes)) {
107 foreach ($rawAttributes[1] as $rawAttribute) {
108 $rawAttribute = explode('=', $rawAttribute);
109 $this->operations[$methodName]['attributes'][$rawAttribute[0]] = $rawAttribute[1];
110 }
111 }
112 }
113 }
114 }
115 return $this->operations;
116 }
117
118 /**
119 * put your comment there...
120 *
121 */
122 public function getInstallerClass() {
123 return $this->installerClass;
124 }
125
126 } // End class.