1 | <?php |
||
10 | class Middleware |
||
11 | { |
||
12 | const KEY = 'Psr7Middlewares\\Middleware'; |
||
13 | const STORAGE_KEY = 'STORAGE_KEY'; |
||
14 | |||
15 | private static $streamFactory; |
||
16 | private static $namespaces = ['Psr7Middlewares\\Middleware\\']; |
||
17 | |||
18 | /** |
||
19 | * Register a new namespace. |
||
20 | * |
||
21 | * @param string $namespace |
||
22 | */ |
||
23 | public static function registerNamespace($namespace) |
||
27 | |||
28 | /** |
||
29 | * Set the stream factory used by some middlewares. |
||
30 | * |
||
31 | * @param callable $streamFactory |
||
32 | */ |
||
33 | public static function setStreamFactory(callable $streamFactory) |
||
37 | |||
38 | /** |
||
39 | * Set the stream factory used by some middlewares. |
||
40 | * |
||
41 | * @param callable|null |
||
42 | */ |
||
43 | public static function getStreamFactory() |
||
47 | |||
48 | /** |
||
49 | * Create instances of the middlewares. |
||
50 | * |
||
51 | * @param string $name |
||
52 | * @param array $args |
||
53 | */ |
||
54 | public static function __callStatic($name, $args) |
||
75 | |||
76 | /** |
||
77 | * Create a middleware callable that acts as a "proxy" to a real middleware that must be returned by the given callback. |
||
78 | * |
||
79 | * @param callable|string $basePath The base path in which the middleware is created (optional) |
||
80 | * @param callable $factory Takes no argument and MUST return a middleware callable or false |
||
81 | * |
||
82 | * @return callable |
||
83 | */ |
||
84 | public static function create($basePath, callable $factory = null) |
||
113 | } |
||
114 |