Changeset 28
- Timestamp:
- 02/09/08 18:23:43 (5 years ago)
- Files:
-
- 1 modified
-
trunk/Phergie/Event/Handler/Command.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Phergie/Event/Handler/Command.php
r24 r28 15 15 protected function processCommand($message, $event) 16 16 { 17 $arguments = preg_split('/[ ]+/', trim($message));18 $command = 'onDo' . ucfirst(strtolower( array_shift($arguments)));19 $arguments[] = $event; 17 preg_match('/^\S+/', $message, $match); 18 $command = 'onDo' . ucfirst(strtolower($match[0])); 19 20 20 if (method_exists($this, $command)) { 21 call_user_func_array(array($this, $command), $arguments); 21 $method = new ReflectionMethod($this, $command); 22 $expected = $method->getNumberOfParameters(); 23 $params = preg_split('/\s+/', $message, $expected + 1); 24 array_shift($params); 25 foreach ($method->getParameters() as $key => $param) { 26 if ($param->getClass()->getName() == 'Phergie_Event_Request') { 27 array_splice($params, $key, 0, array($event)); 28 break; 29 } 30 } 31 if (count($params) == $expected) { 32 call_user_func_array(array($this, $command), $params); 33 } 22 34 } 23 35 }