00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class CallbackCommand extends CommandBase {
00028 protected $callback;
00029 protected $args;
00030
00031 public function __construct($callback, $args = array()) {
00032 $this->callback = $callback;
00033 $this->args = $args;
00034 }
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 public function execute() {
00046 $ret = new Status();
00047 $callable_name = '';
00048 if (!is_callable($this->callback, false, $callable_name)) {
00049 throw new Exception('Callback Command could not call ' . $callable_name . '. Passed callback was: ' . serialize($this->callback));
00050 }
00051 $result = call_user_func_array($this->callback, $this->args);
00052 $ret->merge($result);
00053 return $ret;
00054 }
00055
00056
00057
00058
00059 public function get_name() {
00060 return 'callback';
00061 }
00062
00063 }