Skip to content

Commit

Permalink
fix multiple middleware registered in class annotation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywhalecc committed Jul 14, 2020
1 parent 7b7a2d7 commit c635891
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ZM/Annotation/AnnotationParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function registerMods() {
$class_prefix = '';
$methods = $reflection_class->getMethods(ReflectionMethod::IS_PUBLIC);
$class_annotations = $reader->getClassAnnotations($reflection_class);
$middleware_addon = null;
$middleware_addon = [];
foreach ($class_annotations as $vs) {
if ($vs instanceof Closed) {
continue 2;
Expand Down Expand Up @@ -98,16 +98,18 @@ public static function registerMods() {
ZMBuf::$events[MiddlewareClass::class][$result["name"]] = $result;
continue 2;
} elseif ($vs instanceof Middleware) {
$middleware_addon = $vs;
$middleware_addon[] = $vs;
} elseif ($vs instanceof CustomAnnotation) {
$vs->class = $reflection_class->getName();
ZMBuf::$events[get_class($vs)][] = $vs;
}
}
foreach ($methods as $vs) {
if ($middleware_addon !== null) {
Console::debug("Added middleware " . $middleware_addon->middleware . " to $v -> " . $vs->getName());
ZMBuf::$events[MiddlewareInterface::class][$v][$vs->getName()][] = $middleware_addon->middleware;
if ($middleware_addon !== []) {
foreach($middleware_addon as $value){
Console::debug("Added middleware " . $value->middleware . " to $v -> " . $vs->getName());
ZMBuf::$events[MiddlewareInterface::class][$v][$vs->getName()][] = $value->middleware;
}
}
$method_annotations = $reader->getMethodAnnotations($vs);
foreach ($method_annotations as $vss) {
Expand Down

0 comments on commit c635891

Please sign in to comment.