suivi action
This commit is contained in:
parent
4d883690cb
commit
502331664e
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace nur\sery\output\std;
|
||||
|
||||
use Exception;
|
||||
use nur\sery\output\IMessenger;
|
||||
|
||||
/**
|
||||
|
@ -83,7 +84,21 @@ class ProxyMessenger implements IMessenger {
|
|||
}
|
||||
if ($useFunc && $func !== null) {
|
||||
try {
|
||||
$func($this);
|
||||
$result = $func($this);
|
||||
if ($result !== null) {
|
||||
/** @var _IMessenger $msg */
|
||||
foreach ($this->msgs as $msg) {
|
||||
if ($result === true) $msg->asuccess();
|
||||
elseif ($result === false) $msg->afailure();
|
||||
else $msg->adone($result);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/** @var _IMessenger $msg */
|
||||
foreach ($this->msgs as $msg) {
|
||||
$msg->afailure($e);
|
||||
}
|
||||
throw $e;
|
||||
} finally {
|
||||
/** @var _IMessenger $msg */
|
||||
$index = 0;
|
||||
|
|
|
@ -14,21 +14,21 @@ Application::run(new class extends Application {
|
|||
msg::action("second", function (IMessenger $msg) {
|
||||
msg::action("third", function (IMessenger $msg) {
|
||||
$msg->info("hello world");
|
||||
$msg->asuccess(null, msg::DEBUG);
|
||||
$msg->asuccess();
|
||||
});
|
||||
$msg->asuccess();
|
||||
});
|
||||
$msg->asuccess(null, msg::DEBUG);
|
||||
$msg->asuccess();
|
||||
});
|
||||
msg::action("first2", function (IMessenger $msg) {
|
||||
msg::action("second2", function (IMessenger $msg) {
|
||||
msg::action("third2", function (IMessenger $msg) {
|
||||
$msg->info("hello world2");
|
||||
$msg->asuccess(null, msg::DEBUG);
|
||||
$msg->asuccess();
|
||||
});
|
||||
$msg->asuccess();
|
||||
});
|
||||
$msg->asuccess(null, msg::DEBUG);
|
||||
$msg->asuccess();
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue