1 | <?php |
||
14 | class Framework |
||
15 | { |
||
16 | /** |
||
17 | * Create a new request from the php globals environment. |
||
18 | * |
||
19 | * Note: If you want to use a different PSR-7 implementation this would be |
||
20 | * the proper place to replace the stock implementation of zend\diactoros. |
||
21 | * |
||
22 | * @return Psr\Http\Message\ServerRequestInterface |
||
23 | */ |
||
24 | 9 | public static function requestFromGlobals(): ServerRequestInterface |
|
28 | |||
29 | /** |
||
30 | * Returns the full middleware stack. |
||
31 | * |
||
32 | * @return array |
||
33 | */ |
||
34 | 1 | public static function stack(): array |
|
38 | |||
39 | /** |
||
40 | * Create a middleware stack that is resolvable by PSR-15. |
||
41 | * |
||
42 | * @param array $stack array of callables or strings. |
||
43 | * @return array |
||
44 | */ |
||
45 | 2 | public static function middleware(array $stack): array |
|
52 | |||
53 | /** |
||
54 | * Returns a closure which, when called, will create an instance of the |
||
55 | * class passed to it and then call __invoke() with middleware arguments. |
||
56 | * |
||
57 | * @param string $className fully-qualified name of a class |
||
58 | * @return callable |
||
59 | */ |
||
60 | 2 | public static function lazy(string $className): callable |
|
71 | |||
72 | /** |
||
73 | * Use FastRouter\simpleDispatcher to collect the routes into a FastRoute\Dispatcher. |
||
74 | * |
||
75 | * @param Psr\Http\Message\ServerRequestInterface $request |
||
76 | * @param string $path |
||
77 | * @return Psr\Http\Message\ResponseInterface |
||
78 | */ |
||
79 | 2 | public static function router(ServerRequestInterface $request, string $path = null): ResponseInterface |
|
88 | |||
89 | /** |
||
90 | * Resolve an HTTP request match. |
||
91 | * |
||
92 | * @param Psr\Http\Message\ServerRequestInterface $request |
||
93 | * @param array $match Route match. When using fast router will be array. |
||
94 | * @return Psr\Http\Message\ResponseInterface |
||
95 | */ |
||
96 | 3 | public static function resolve(ServerRequestInterface $request, array $match): ResponseInterface |
|
108 | |||
109 | /** |
||
110 | * Load a given configuration file or array. |
||
111 | * |
||
112 | * @param string $name config file name |
||
113 | * @param string $dir path to directory storing the config file |
||
114 | * @return array |
||
115 | */ |
||
116 | 4 | public static function config(string $name, string $dir = null): array |
|
129 | |||
130 | /** |
||
131 | * Get the rendering engine. |
||
132 | * |
||
133 | * @return League\Plates\Engine |
||
134 | */ |
||
135 | 1 | public static function engine(): Engine |
|
139 | |||
140 | /** |
||
141 | * Render a given view with our template engine. |
||
142 | * |
||
143 | * @param string $view name of the view |
||
144 | * @param array $data data to pass through to our template |
||
145 | * @param Engine $engine alternative rendering engine |
||
146 | * @return string |
||
147 | */ |
||
148 | 2 | public static function render(string $view, array $data, Engine $engine = null): string |
|
153 | } |
||
154 |