controllerFullName(); $methodAnnotations = Annotation::getMethodAnnotation($className, $request->method()); $reflectionClass = Application::getReflectionClass($className); // 前置操作 if (isset($methodAnnotations['beforeAction'])) { $functions = explode('|', $methodAnnotations['beforeAction']); foreach ($functions as $function) { if (substr($function, 0, 1) == '_' && $reflectionClass->hasMethod($function)) { $beforeData = (Application::getReflectionMethod($request->controllerFullName(), $function))->invoke(Application::getInstance($request->controllerFullName())); if (!empty($beforeData)) return $beforeData; } } $functions = null; } $closure = $next(); // 后置操作 if (isset($methodAnnotations['afterAction'])) { $functions = explode('|', $methodAnnotations['afterAction']); foreach ($functions as $function) { if (substr($function, 0, 1) == '_' && $reflectionClass->hasMethod($function)) { (Application::getReflectionMethod($request->controllerFullName(), $function))->invoke(Application::getInstance($request->controllerFullName())); } } } return $closure; } }