This commit is contained in:
2021-03-03 19:35:44 +08:00
parent 7eee4a057e
commit edf82a4bf1
2 changed files with 31 additions and 31 deletions
+2 -26
View File
@@ -465,7 +465,7 @@ class Server extends HttpService
$router = Snowflake::app()->getRouter();
$router->loadRouterSetting();
recursive_directory(SOCKET_PATH, [$this, 'recursive_callback']);
recursive_directory(SOCKET_PATH);
});
}
@@ -477,35 +477,11 @@ class Server extends HttpService
{
$event = Snowflake::app()->getEvent();
$event->on(Event::SERVER_WORKER_START, function () {
recursive_directory(SOCKET_PATH, [$this, 'recursive_callback']);
recursive_directory(SOCKET_PATH);
});
}
/**
* @param DirectoryIterator $file
* @throws ComponentException
* @throws NotFindClassException
* @throws ReflectionException
*/
public function recursive_callback(DirectoryIterator $file)
{
$attributes = Snowflake::app()->getAttributes();
$annotations = $attributes->getFilename($file->getRealPath());
if (empty($annotations)) {
return;
}
/** @var Attribute $attribute */
foreach ($annotations['methods'] as $name => $attribute) {
if (!($attribute instanceof Attribute)) {
continue;
}
$attribute->execute([$annotations['handler'], $name]);
}
}
/**
* @param $type