This commit is contained in:
2021-02-23 14:17:56 +08:00
parent 9e6ac6d92d
commit c0cd71efe9
2 changed files with 3 additions and 19 deletions
+3 -6
View File
@@ -59,7 +59,7 @@ class Annotation extends Component
* @param string $namespace * @param string $namespace
* @param string $alias * @param string $alias
* @return $this * @return $this
* @throws ReflectionException|NotFindPropertyException * @throws ReflectionException|NotFindPropertyException|NotFindClassException
*/ */
public function readControllers(string $path, string $namespace, string $alias = 'root'): static public function readControllers(string $path, string $namespace, string $alias = 'root'): static
{ {
@@ -213,9 +213,6 @@ class Annotation extends Component
} }
$name = get_class($object) . '_' . $method->getName(); $name = get_class($object) . '_' . $method->getName();
if (!isset($this->_annotations[$alias])) {
$this->_annotations[$alias] = [];
}
if (!isset($this->_annotations[$alias][$name])) { if (!isset($this->_annotations[$alias][$name])) {
$this->_annotations[$alias][$name] = []; $this->_annotations[$alias][$name] = [];
} }
@@ -239,9 +236,9 @@ class Annotation extends Component
* @param $class * @param $class
* @param $method * @param $method
* @param string $alias * @param string $alias
* @return array|mixed * @return mixed
*/ */
public function getAnnotationByMethod($class, $method, $alias = '') public function getAnnotationByMethod($class, $method, $alias = ''): mixed
{ {
if (!isset($this->_annotations[$alias])) { if (!isset($this->_annotations[$alias])) {
return []; return [];
-13
View File
@@ -488,19 +488,6 @@ class Server extends HttpService
$event->on(Event::SERVER_WORKER_START, function () { $event->on(Event::SERVER_WORKER_START, function () {
$attributes = Snowflake::app()->getAttributes(); $attributes = Snowflake::app()->getAttributes();
$attributes->readControllers(SOCKET_PATH, 'App\Websocket', 'sockets'); $attributes->readControllers(SOCKET_PATH, 'App\Websocket', 'sockets');
$aliases = $attributes->getAlias('sockets');
if (count($aliases) < 1) {
return;
}
foreach ($aliases as $alias) {
$handler = $alias['handler'];
foreach ($alias['attributes'] as $key => $attribute) {
if ($attribute instanceof IAnnotation) {
$attribute->execute($handler);
}
}
}
}); });
} }