mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 01:38:41 +00:00
allow event trigger passing
This commit is contained in:
parent
c20021464c
commit
df89ee433e
|
|
@ -65,6 +65,7 @@ final class Dispatcher implements DispatcherInterface
|
|||
public function dispatch(array | string | \Closure $controller, ...$data) : array
|
||||
{
|
||||
$views = [];
|
||||
$data = $data !== null ? \array_values($data) : null;
|
||||
|
||||
if (\is_array($controller) && isset($controller['dest'])) {
|
||||
if (!empty($controller['data'])) {
|
||||
|
|
|
|||
|
|
@ -207,6 +207,12 @@ final class EventManager implements \Countable
|
|||
}
|
||||
}
|
||||
|
||||
if (!\is_array($data)) {
|
||||
$data = [$data];
|
||||
}
|
||||
|
||||
$data[':triggerGroup'] ??= $group;
|
||||
|
||||
$triggerValue = false;
|
||||
foreach ($groups as $groupName => $ids) {
|
||||
foreach ($ids as $id) {
|
||||
|
|
@ -244,10 +250,18 @@ final class EventManager implements \Countable
|
|||
|
||||
foreach ($this->callbacks[$group]['callbacks'] as $func) {
|
||||
if (\is_array($data)) {
|
||||
$this->dispatcher->dispatch($func, ...$data);
|
||||
$data[':triggerGroup'] ??= $group;
|
||||
$data[':triggerId'] = $id;
|
||||
} else {
|
||||
$this->dispatcher->dispatch($func, $data);
|
||||
$data = [
|
||||
$data,
|
||||
];
|
||||
|
||||
$data[':triggerGroup'] ??= $group;
|
||||
$data[':triggerId'] = $id;
|
||||
}
|
||||
|
||||
$this->dispatcher->dispatch($func, ...$data);
|
||||
}
|
||||
|
||||
if ($this->callbacks[$group]['remove']) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user