ach($this->_callback_method[$eventstr] as $v){
if($method==$v[''function'']){
return true;
}
}
}
}
return false;
}
/**
* 检测指定类是否存在指定方法
* @param string $class
* @param string $method
* @exception Exception_Event
* @return void
*/
private function _check_method($class,$method){
if(!method_exists($class,$method)){
throw new Exception(get_class($class)." not exist ".$method." method",1);
}
}
/**
* 检测指定函数是否存在
* @param string $function
* @return void
*/
private function _check_function($function){
if(!function_exists($function)){
throw new Exception($function." function not exist ",2);
}
}
/**
* 检测指定事件是否存在监听函数
* @param string $eventstr
* @return boolean
*/
private function _check_callback($eventstr){
if(isset($this->_callback_method[$eventstr])
&&is_array($this->_callback_method[$eventstr])
){
return true;
}
return false;
}
/**
* 创建监听函数数组
* @param string $eventstr
* @param string $function
* @return array
*/
private function _create_listener_fn($eventstr,$function){
return array(
"object"=>false,
"function"=>$function,
);
}
/**
* 创建监听类数组
* @param string $eventstr
* @param string $class
* @param string $method
* @return array
*/
private function _create_listener_method($eventstr,$class,$method){
return array(
"object"=>true,
"class"=>$class,
"method"=>$method,
);
}
}
class myevent extends Event{
const aa=''aaa'';
}
class ball extends EventDispatcher{
public function aa(){
$event=new myevent(myevent::aa);
$this->dispatch($event);
}
}
class mytest {
public function test(){
$ball=new ball();
$ball->attach(myevent::aa,''kk'');
$ball->aa();
}
public function kk($e){
print_r($e);
}
}
try{
$t=new mytest();
$t->test();
}catch (Exception $e){
echo $e->getmessage();
}