改名
This commit is contained in:
@@ -186,12 +186,27 @@ abstract class BaseApplication extends Service
|
|||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
$value = Snowflake::createObject($value);
|
$value = Snowflake::createObject($value);
|
||||||
}
|
}
|
||||||
if (is_array($value) && isset($value[0]) && !($value[0] instanceof \Closure)) {
|
$this->addEvent($event, $key, $value);
|
||||||
if (!is_callable($value, true)) {
|
|
||||||
throw new InitException("Class does not hav callback.");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $event
|
||||||
|
* @param $key
|
||||||
|
* @param $value
|
||||||
|
* @throws InitException
|
||||||
|
*/
|
||||||
|
private function addEvent($event, $key, $value): void
|
||||||
|
{
|
||||||
|
if ($value instanceof \Closure) {
|
||||||
$event->on($key, $value, [], true);
|
$event->on($key, $value, [], true);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
if (isset($value[0]) && is_object($value[0])) {
|
||||||
|
$event->on($key, $value, [], true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach ($value as $item) {
|
foreach ($value as $item) {
|
||||||
if (!is_callable($item, true)) {
|
if (!is_callable($item, true)) {
|
||||||
throw new InitException("Class does not hav callback.");
|
throw new InitException("Class does not hav callback.");
|
||||||
@@ -199,8 +214,6 @@ abstract class BaseApplication extends Service
|
|||||||
$event->on($key, $item, [], true);
|
$event->on($key, $item, [], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user