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 / events / hookable.class.php

hookable.class.php in CSS & JavaScript Toolbox 11.2, at framework/events/hookable.class.php

147 lines 3.1 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 abstract class CJTHookableClass implements CJTIHookable {
10
11 /**
12 * put your comment there...
13 *
14 * @var mixed
15 */
16 protected $events;
17
18 /**
19 * put your comment there...
20 *
21 * @param mixed $options
22 * @return CJTHookableClass
23 */
24 protected function __construct($options = array()) {
25 $this->events = new CJTWordpressEvents($this, $options);
26 }
27
28 /**
29 * put your comment there...
30 *
31 * @param mixed $type
32 * @param mixed $params
33 */
34 public function __call($typeName, $params) {
35 return $this->events->trigger($typeName, $params);
36 }
37
38 /**
39 * put your comment there...
40 *
41 * @param mixed $type
42 * @param mixed $params
43 */
44 public static function __callStatic($typeName, $params) {
45 return CJTWordpressEvents::getTypeEvents($typeName)->trigger($typeName, $params);
46 }
47
48 /**
49 * put your comment there...
50 *
51 * @param mixed $type
52 */
53 public function __get($typeName) {
54 return $this->events->getSubject($typeName);
55 }
56
57 /**
58 * put your comment there...
59 *
60 * @param mixed $type
61 * @param mixed $observer
62 */
63 public function __set($typeName, $observer) {
64 $this->events->bind($typeName, $observer);
65 }
66
67 /**
68 * put your comment there...
69 *
70 * @param mixed $type
71 * @param mixed $observer
72 */
73 public function bind($typeName, $observer) {
74 $events =(isset($this) && isset($this->events)) ?
75 $this->events :
76 CJTWordpressEvents::getTypeEvents($typeName, false);
77 return $events->bind($typeName, $observer, false);
78 }
79
80 /**
81 * put your comment there...
82 *
83 * @param mixed $class
84 * @param mixed $options
85 */
86 public static function define($class, $options = array()) {
87 return new CJTWordpressEvents($class, $options, true);
88 }
89
90 /**
91 * put your comment there...
92 *
93 */
94 public function iEvents() {
95 return $this->events;
96 }
97
98 /**
99 * put your comment there...
100 *
101 * @param mixed $typeName
102 * @param mixed $observer
103 */
104 public static function off($typeName, $observer) {
105 return CJTWordpressEvents::off($typeName, $observer);
106 }
107
108 /**
109 * put your comment there...
110 *
111 * @param mixed $typeName
112 * @param mixed $observer
113 */
114 public static function on($typeName, $observer) {
115 return CJTWordpressEvents::on($typeName, $observer);
116 }
117
118 /**
119 * put your comment there...
120 *
121 * @param mixed $type
122 */
123 public static function trigger($typeName) {
124 $events = (isset($this) && isset($this->events)) ?
125 $this->events :
126 CJTWordpressEvents::getTypeEvents($typeName, false);
127 // Get passed parameters!
128 $params = func_get_args();
129 unset($params[0]);
130 // Trigger the event!
131 return $events->trigger($typeName, $params, false);
132 }
133
134 /**
135 * put your comment there...
136 *
137 * @param mixed $type
138 * @param mixed $observer
139 */
140 public function unbind($typeName, $observer) {
141 $events = (isset($this) && isset($this->events)) ?
142 $this->events :
143 CJTWordpressEvents::getTypeEvents($typeName, false);
144 return $events->unbind($typeName, $observer, false);
145 }
146
147 } // End class