| @@ -1,87 +1,87 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* | |
| 3 | +* | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | -* | |
| 7 | +* | |
| 8 | 8 | */ |
| 9 | 9 | abstract class CJTEvents { |
| 10 | - | |
| 10 | + | |
| 11 | 11 | /** |
| 12 | 12 | * put your comment there... |
| 13 | - * | |
| 13 | + * | |
| 14 | 14 | * @var mixed |
| 15 | 15 | */ |
| 16 | 16 | protected static $classes = array(); |
| 17 | - | |
| 17 | + | |
| 18 | 18 | /** |
| 19 | 19 | * put your comment there... |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * @var mixed |
| 22 | 22 | */ |
| 23 | 23 | public static $defaultOptions = array('prefix' => 'on'); |
| 24 | - | |
| 24 | + | |
| 25 | 25 | /** |
| 26 | 26 | * put your comment there... |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * @var mixed |
| 29 | 29 | */ |
| 30 | 30 | public static $definition; |
| 31 | - | |
| 31 | + | |
| 32 | 32 | /** |
| 33 | 33 | * put your comment there... |
| 34 | - * | |
| 34 | + * | |
| 35 | 35 | * @var mixed |
| 36 | 36 | */ |
| 37 | 37 | protected $freeStatic; |
| 38 | - | |
| 38 | + | |
| 39 | 39 | /** |
| 40 | 40 | * put your comment there... |
| 41 | - * | |
| 41 | + * | |
| 42 | 42 | * @var mixed |
| 43 | 43 | */ |
| 44 | 44 | protected static $live; |
| 45 | - | |
| 45 | + | |
| 46 | 46 | /** |
| 47 | 47 | * put your comment there... |
| 48 | - * | |
| 48 | + * | |
| 49 | 49 | * @var mixed |
| 50 | 50 | */ |
| 51 | 51 | private $options = array(); |
| 52 | - | |
| 52 | + | |
| 53 | 53 | /** |
| 54 | 54 | * put your comment there... |
| 55 | - * | |
| 55 | + * | |
| 56 | 56 | * @var mixed |
| 57 | 57 | */ |
| 58 | 58 | public static $paths = array(); |
| 59 | - | |
| 59 | + | |
| 60 | 60 | /** |
| 61 | 61 | * put your comment there... |
| 62 | - * | |
| 62 | + * | |
| 63 | 63 | * @var mixed |
| 64 | 64 | */ |
| 65 | 65 | protected $subjects; |
| 66 | - | |
| 66 | + | |
| 67 | 67 | /** |
| 68 | 68 | * put your comment there... |
| 69 | - * | |
| 69 | + * | |
| 70 | 70 | * @var mixed |
| 71 | 71 | */ |
| 72 | 72 | private $target; |
| 73 | - | |
| 73 | + | |
| 74 | 74 | /** |
| 75 | 75 | * put your comment there... |
| 76 | - * | |
| 76 | + * | |
| 77 | 77 | * @var mixed |
| 78 | 78 | */ |
| 79 | 79 | private $targetClass; |
| 80 | - | |
| 80 | + | |
| 81 | 81 | /** |
| 82 | 82 | * put your comment there... |
| 83 | - * | |
| 83 | + * | |
| 84 | 84 | * @param mixed $target |
| 85 | 85 | * @param mixed $options |
| 86 | 86 | * @return CJTEvents |
| 87 | 87 | */ |
| @@ -93,15 +93,15 @@ | ||
| 93 | 93 | $this->targetClass = is_object($this->target) ? get_class($this->target) : $this->target; |
| 94 | 94 | // Define class events if not defined yet! |
| 95 | 95 | $this->define(); |
| 96 | 96 | } |
| 97 | - | |
| 97 | + | |
| 98 | 98 | /** |
| 99 | 99 | * put your comment there... |
| 100 | - * | |
| 100 | + * | |
| 101 | 101 | * @param mixed $options |
| 102 | 102 | */ |
| 103 | - public static function _init($options = array()) { | |
| 103 | + public static function __init($options = array()) { | |
| 104 | 104 | if (!self::$definition) { |
| 105 | 105 | self::$defaultOptions += $options; |
| 106 | 106 | // Definition object! |
| 107 | 107 | self::$definition = (new CJTEventsDefinition()); |
| @@ -112,9 +112,9 @@ | ||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * put your comment there... |
| 116 | - * | |
| 116 | + * | |
| 117 | 117 | * @param mixed $typeName |
| 118 | 118 | * @param mixed $observer |
| 119 | 119 | * @param mixed $typePrefixed |
| 120 | 120 | * @return CJTEvents |
| @@ -127,9 +127,9 @@ | ||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * put your comment there... |
| 131 | - * | |
| 131 | + * | |
| 132 | 132 | * @param mixed $type |
| 133 | 133 | */ |
| 134 | 134 | public function createSubject($event) { |
| 135 | 135 | // Initializing! |
| @@ -150,9 +150,9 @@ | ||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * put your comment there... |
| 154 | - * | |
| 154 | + * | |
| 155 | 155 | */ |
| 156 | 156 | protected function define() { |
| 157 | 157 | $className = $this->targetClass; |
| 158 | 158 | if (!isset(self::$classes[$className])) { |
| @@ -165,9 +165,9 @@ | ||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * put your comment there... |
| 169 | - * | |
| 169 | + * | |
| 170 | 170 | * @deprecated |
| 171 | 171 | */ |
| 172 | 172 | private function findEvents() { |
| 173 | 173 | // If the class is not defined, define it! |
| @@ -184,21 +184,21 @@ | ||
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | - | |
| 188 | + | |
| 189 | 189 | /** |
| 190 | 190 | * put your comment there... |
| 191 | - * | |
| 191 | + * | |
| 192 | 192 | * @param mixed $class |
| 193 | 193 | */ |
| 194 | 194 | public function getDefinition() { |
| 195 | 195 | return self::$definition->get($this->targetClass); |
| 196 | 196 | } |
| 197 | - | |
| 197 | + | |
| 198 | 198 | /** |
| 199 | 199 | * put your comment there... |
| 200 | - * | |
| 200 | + * | |
| 201 | 201 | * @param mixed $type |
| 202 | 202 | */ |
| 203 | 203 | public function getSubject($type) { |
| 204 | 204 | // Initialize. |
| @@ -219,19 +219,19 @@ | ||
| 219 | 219 | $lives = isset(self::$live[$this->targetClass][$event['id']]) ? self::$live[$this->targetClass][$event['id']] : array(); |
| 220 | 220 | foreach ($lives as $live) { |
| 221 | 221 | $subject[] = $live['observer']; |
| 222 | 222 | } |
| 223 | - } | |
| 223 | + } | |
| 224 | 224 | return $this->subjects[$type->name]; |
| 225 | 225 | } |
| 226 | - | |
| 226 | + | |
| 227 | 227 | /** |
| 228 | 228 | * put your comment there... |
| 229 | - * | |
| 229 | + * | |
| 230 | 230 | * @param mixed $type |
| 231 | 231 | * @return CJTWordpressEvents |
| 232 | 232 | */ |
| 233 | - public static function getTypeEvents($typeName, $typePrefixed = true) { | |
| 233 | + public function getTypeEvents($typeName, $typePrefixed = true) { | |
| 234 | 234 | $type = self::parseEventType($typeName, $typePrefixed); |
| 235 | 235 | if (!self::$classes[$type->class]) { |
| 236 | 236 | throw new Exception("Type not found!! Could not find {$typeName}!"); |
| 237 | 237 | } |
| @@ -236,34 +236,34 @@ | ||
| 236 | 236 | throw new Exception("Type not found!! Could not find {$typeName}!"); |
| 237 | 237 | } |
| 238 | 238 | return self::$classes[$type->class]; |
| 239 | 239 | } |
| 240 | - | |
| 240 | + | |
| 241 | 241 | /** |
| 242 | 242 | * put your comment there... |
| 243 | - * | |
| 243 | + * | |
| 244 | 244 | */ |
| 245 | 245 | public function isFreeStatic() { |
| 246 | - return $this->freeStatic; | |
| 246 | + return $this->freeStatic; | |
| 247 | 247 | } |
| 248 | - | |
| 248 | + | |
| 249 | 249 | /** |
| 250 | 250 | * put your comment there... |
| 251 | - * | |
| 251 | + * | |
| 252 | 252 | * @param mixed $typeName |
| 253 | 253 | * @param mixed $observer |
| 254 | 254 | */ |
| 255 | 255 | public function off($typeName, $observer) { |
| 256 | - | |
| 256 | + | |
| 257 | 257 | } |
| 258 | - | |
| 258 | + | |
| 259 | 259 | /** |
| 260 | 260 | * put your comment there... |
| 261 | - * | |
| 261 | + * | |
| 262 | 262 | * @param mixed $typeName |
| 263 | 263 | * @param mixed $observer |
| 264 | 264 | */ |
| 265 | - public static function on($typeName, $observer) { | |
| 265 | + public function on($typeName, $observer) { | |
| 266 | 266 | $type = self::parseEventType($typeName, false); |
| 267 | 267 | // Create live event! |
| 268 | 268 | $on = array(); |
| 269 | 269 | $on['observer'] = $observer; |
| @@ -268,15 +268,15 @@ | ||
| 268 | 268 | $on = array(); |
| 269 | 269 | $on['observer'] = $observer; |
| 270 | 270 | self::$live[$type->class][$type->name][] = $on; |
| 271 | 271 | } |
| 272 | - | |
| 272 | + | |
| 273 | 273 | /** |
| 274 | 274 | * put your comment there... |
| 275 | - * | |
| 275 | + * | |
| 276 | 276 | * @param mixed $type |
| 277 | 277 | */ |
| 278 | - public static function parseEventType($type, $typePrefixed = true) { | |
| 278 | + public function parseEventType($type, $typePrefixed = true) { | |
| 279 | 279 | $separator = '.'; |
| 280 | 280 | $prefix = 'on'; |
| 281 | 281 | // CLASS.TYPE |
| 282 | 282 | $parts = explode('.', $type); |
| @@ -299,34 +299,34 @@ | ||
| 299 | 299 | $type['type'] = "on{$type['type']}"; |
| 300 | 300 | } |
| 301 | 301 | return ((object) $type); |
| 302 | 302 | } |
| 303 | - | |
| 303 | + | |
| 304 | 304 | /** |
| 305 | 305 | * put your comment there... |
| 306 | - * | |
| 306 | + * | |
| 307 | 307 | * @param mixed $type |
| 308 | 308 | */ |
| 309 | 309 | protected function prepareEventTypeOptions($event) { |
| 310 | - return $event; | |
| 310 | + return $event; | |
| 311 | 311 | } |
| 312 | - | |
| 312 | + | |
| 313 | 313 | /** |
| 314 | 314 | * put your comment there... |
| 315 | - * | |
| 315 | + * | |
| 316 | 316 | * @param mixed $type |
| 317 | 317 | * @param mixed $params |
| 318 | 318 | * @param mixed $typePrefixed |
| 319 | 319 | */ |
| 320 | 320 | public abstract function trigger($type, $params = array(), $typePrefixed = true); |
| 321 | - | |
| 321 | + | |
| 322 | 322 | /** |
| 323 | 323 | * put your comment there... |
| 324 | - * | |
| 324 | + * | |
| 325 | 325 | * @param mixed $type |
| 326 | 326 | * @param mixed $observer |
| 327 | 327 | */ |
| 328 | 328 | public function unbind($type, $observer, $typePrefixed = true) { |
| 329 | - | |
| 329 | + | |
| 330 | 330 | } |
| 331 | - | |
| 331 | + | |
| 332 | 332 | } // End class. |