改名
This commit is contained in:
+18
-16
@@ -4,6 +4,7 @@
|
|||||||
namespace HttpServer;
|
namespace HttpServer;
|
||||||
|
|
||||||
use Annotation\Attribute;
|
use Annotation\Attribute;
|
||||||
|
use DirectoryIterator;
|
||||||
use HttpServer\Abstracts\Callback;
|
use HttpServer\Abstracts\Callback;
|
||||||
use HttpServer\Abstracts\HttpService;
|
use HttpServer\Abstracts\HttpService;
|
||||||
use HttpServer\Events\OnClose;
|
use HttpServer\Events\OnClose;
|
||||||
@@ -464,19 +465,7 @@ class Server extends HttpService
|
|||||||
$router = Snowflake::app()->getRouter();
|
$router = Snowflake::app()->getRouter();
|
||||||
$router->loadRouterSetting();
|
$router->loadRouterSetting();
|
||||||
|
|
||||||
$attributes = Snowflake::app()->getAttributes();
|
recursive_directory(SOCKET_PATH, [$this, 'recursive_callback']);
|
||||||
|
|
||||||
recursive_directory(CONTROLLER_PATH, function (\DirectoryIterator $file) use ($attributes) {
|
|
||||||
$annotations = $attributes->getFilename($file->getRealPath());
|
|
||||||
|
|
||||||
/** @var Attribute $attribute */
|
|
||||||
foreach ($annotations['methods'] as $name => $attribute) {
|
|
||||||
if (!($attribute instanceof Attribute)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$attribute->execute([$annotations['handler'], $name]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,10 +477,25 @@ class Server extends HttpService
|
|||||||
{
|
{
|
||||||
$event = Snowflake::app()->getEvent();
|
$event = Snowflake::app()->getEvent();
|
||||||
$event->on(Event::SERVER_WORKER_START, function () {
|
$event->on(Event::SERVER_WORKER_START, function () {
|
||||||
|
recursive_directory(SOCKET_PATH, [$this, 'recursive_callback']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param DirectoryIterator $file
|
||||||
|
* @throws ComponentException
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
public function recursive_callback(DirectoryIterator $file)
|
||||||
|
{
|
||||||
$attributes = Snowflake::app()->getAttributes();
|
$attributes = Snowflake::app()->getAttributes();
|
||||||
|
|
||||||
recursive_directory(SOCKET_PATH, function (\DirectoryIterator $file) use ($attributes) {
|
|
||||||
$annotations = $attributes->getFilename($file->getRealPath());
|
$annotations = $attributes->getFilename($file->getRealPath());
|
||||||
|
if (empty($annotations)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var Attribute $attribute */
|
/** @var Attribute $attribute */
|
||||||
foreach ($annotations['methods'] as $name => $attribute) {
|
foreach ($annotations['methods'] as $name => $attribute) {
|
||||||
@@ -500,8 +504,6 @@ class Server extends HttpService
|
|||||||
}
|
}
|
||||||
$attribute->execute([$annotations['handler'], $name]);
|
$attribute->execute([$annotations['handler'], $name]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user