# Zhamao Framework: MiddlewareHandler类 参考

MiddlewareHandler类 参考

## Public 成员函数

| registerBefore (string $name, callable $callback)
| registerAfter (string $name, callable $callback)
| registerException (string $name, string $exception_class, callable $callback)
| bindMiddleware (callable $callback, string $name, array $params=[])
| getPipeClosure (callable $callback, $stack_id)
| process (callable $callback,... $args)
| getCurrentCallable ()
| getStackId (callable $callback)

## Protected 属性

array | $middlewares = []
array | $reg_map = []
array | $stack = []
array | $callable_stack = []

## 成员函数说明

## bindMiddleware()

bindMiddleware | ( | callable | $callback,
|  | string | $name,
|  | array | $params = `[]`
| ) |  |

异常

  InvalidArgumentException |

函数调用图:

## getCurrentCallable()

getCurrentCallable | ( |  | ) |

获取正在运行的回调调用对象，可能是Closure、array、string

返回
  false|mixed

## getPipeClosure()

getPipeClosure | ( | callable | $callback,
|  |  | $stack_id
| ) |  |

函数调用图:

## getStackId()

getStackId | ( | callable | $callback | ) |

参数

  callable | $callback | 可执行的方法

异常

  InvalidArgumentException |

## process()

process | ( | callable | $callback,
|  |  | $args
| ) |  |

异常

  InvalidArgumentException |

函数调用图:

## registerAfter()

registerAfter | ( | string | $name,
|  | callable | $callback
| ) |  |

## registerBefore()

registerBefore | ( | string | $name,
|  | callable | $callback
| ) |  |

## registerException()

registerException | ( | string | $name,
|  | string | $exception_class,
|  | callable | $callback
| ) |  |

## 结构体成员变量说明

## $callable_stack

array $callable_stack = []

protected

## $middlewares

array $middlewares = []

protected

## $reg_map

array $reg_map = []

protected

## $stack

array $stack = []

protected

该类的文档由以下文件生成:

- src/ZM/Middleware/MiddlewareHandler.php