diff --git a/Annotation/After.php b/Annotation/After.php deleted file mode 100644 index 2c63417f..00000000 --- a/Annotation/After.php +++ /dev/null @@ -1,33 +0,0 @@ -handler; - } - - -} diff --git a/Annotation/IAnnotation.php b/Annotation/IAnnotation.php index fd5b3e88..00639a1c 100644 --- a/Annotation/IAnnotation.php +++ b/Annotation/IAnnotation.php @@ -11,10 +11,11 @@ interface IAnnotation /** - * @param array|Closure $closure + * @param array|Closure $handler + * @param array $attributes * @return mixed */ - public function setHandler(array|Closure $closure): mixed; + public function setHandler(array|Closure $handler, array $attributes): mixed; } diff --git a/Annotation/Interceptor.php b/Annotation/Interceptor.php deleted file mode 100644 index 77531faf..00000000 --- a/Annotation/Interceptor.php +++ /dev/null @@ -1,33 +0,0 @@ -handler; - } - - -} diff --git a/Annotation/Limits.php b/Annotation/Limits.php deleted file mode 100644 index 19f167bb..00000000 --- a/Annotation/Limits.php +++ /dev/null @@ -1,33 +0,0 @@ -handler; - } - - -} diff --git a/Annotation/Middleware.php b/Annotation/Middleware.php deleted file mode 100644 index 5bff8a95..00000000 --- a/Annotation/Middleware.php +++ /dev/null @@ -1,33 +0,0 @@ -handler; - } - - -} diff --git a/Annotation/RequestValidator.php b/Annotation/RequestValidator.php new file mode 100644 index 00000000..edcc6c42 --- /dev/null +++ b/Annotation/RequestValidator.php @@ -0,0 +1,23 @@ +middleware)) { + $node->addMiddleware($this->middleware); + } + if (!empty($this->interceptor)) { + $node->addInterceptor($this->interceptor); + } + if (!empty($this->limits)) { + $node->addLimits($this->limits); + } + if (!empty($this->after)) { + $node->addAfter($this->after); + } + return $node; + } + +} diff --git a/Annotation/Route.php b/Annotation/Route/Route.php similarity index 78% rename from Annotation/Route.php rename to Annotation/Route/Route.php index 3e073ff6..48bffebb 100644 --- a/Annotation/Route.php +++ b/Annotation/Route/Route.php @@ -1,18 +1,21 @@ addRoute($this->uri, $handler, $this->method); - foreach ($attributes as $name => $attribute) { - $first = 'add' . ucfirst($attribute); - $_handler = is_array($handler) ? $handler[0] : $handler; - if (!method_exists($_handler, $first)) { - continue; - } - $node->$first($attribute); - } - return $node; + return $this->add($node); } diff --git a/Annotation/Route/Socket.php b/Annotation/Route/Socket.php new file mode 100644 index 00000000..bdad21fb --- /dev/null +++ b/Annotation/Route/Socket.php @@ -0,0 +1,70 @@ +getRouter(); + // TODO: Implement setHandler() method. + + $method = $this->event . '::' . ($this->uri ?? 'event'); + $node = $router->addRoute($method, $handler, 'sw::socket'); + + return $this->add($node); + } + +} diff --git a/Annotation/Socket.php b/Annotation/Socket.php deleted file mode 100644 index aec9fccd..00000000 --- a/Annotation/Socket.php +++ /dev/null @@ -1,52 +0,0 @@ -getRouter(); - // TODO: Implement setHandler() method. - - $method = $this->event . '::' . ($this->uri ?? 'event'); - - return $router->addRoute($method, $closure, 'sw::socket'); - } - -}