mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 17:15:36 +08:00
update to 2.0.0-b6 version
add interrupt return_value to InterruptException
This commit is contained in:
@@ -29,10 +29,11 @@ class EventDispatcher
|
|||||||
private $eid = 0;
|
private $eid = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param null $return_var
|
||||||
* @throws InterruptException
|
* @throws InterruptException
|
||||||
*/
|
*/
|
||||||
public static function interrupt() {
|
public static function interrupt($return_var = null) {
|
||||||
throw new InterruptException('interrupt');
|
throw new InterruptException($return_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function enableEventTrace($event_class) {
|
public static function enableEventTrace($event_class) {
|
||||||
@@ -85,7 +86,7 @@ class EventDispatcher
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (InterruptException $e) {
|
} catch (InterruptException $e) {
|
||||||
return null;
|
return $e->return_var;
|
||||||
} catch (AnnotationException $e) {
|
} catch (AnnotationException $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -95,9 +96,9 @@ class EventDispatcher
|
|||||||
* @param AnnotationBase|null $v
|
* @param AnnotationBase|null $v
|
||||||
* @param null $rule_func
|
* @param null $rule_func
|
||||||
* @param mixed ...$params
|
* @param mixed ...$params
|
||||||
* @return bool
|
|
||||||
* @throws AnnotationException
|
* @throws AnnotationException
|
||||||
* @throws InterruptException
|
* @throws InterruptException
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function dispatchEvent(?AnnotationBase $v, $rule_func = null, ...$params) {
|
public function dispatchEvent(?AnnotationBase $v, $rule_func = null, ...$params) {
|
||||||
$q_c = $v->class;
|
$q_c = $v->class;
|
||||||
|
|||||||
@@ -4,7 +4,14 @@
|
|||||||
namespace ZM\Exception;
|
namespace ZM\Exception;
|
||||||
|
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class InterruptException extends ZMException
|
class InterruptException extends ZMException
|
||||||
{
|
{
|
||||||
|
public $return_var = null;
|
||||||
|
|
||||||
|
public function __construct($return_var = null, $message = "", $code = 0, Throwable $previous = null) {
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
$this->return_var = $return_var;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user