|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
use Ecodev\Felix\Handler\GraphQLHandler; |
|
6
|
|
|
use GraphQL\Upload\UploadMiddleware; |
|
7
|
|
|
use Mezzio\Application; |
|
8
|
|
|
use Mezzio\Helper\BodyParams\BodyParamsMiddleware; |
|
9
|
|
|
use Mezzio\MiddlewareFactory; |
|
10
|
|
|
use Psr\Container\ContainerInterface; |
|
11
|
|
|
|
|
12
|
|
|
/* |
|
13
|
|
|
* Setup routes with a single request method: |
|
14
|
|
|
* |
|
15
|
|
|
* $app->get('/', App\Handler\HomePageHandler::class, 'home'); |
|
16
|
|
|
* $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create'); |
|
17
|
|
|
* $app->put('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.put'); |
|
18
|
|
|
* $app->patch('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.patch'); |
|
19
|
|
|
* $app->delete('/album/:id', App\Handler\AlbumDeleteHandler::class, 'album.delete'); |
|
20
|
|
|
* |
|
21
|
|
|
* Or with multiple request methods: |
|
22
|
|
|
* |
|
23
|
|
|
* $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact'); |
|
24
|
|
|
* |
|
25
|
|
|
* Or handling all request methods: |
|
26
|
|
|
* |
|
27
|
|
|
* $app->route('/contact', App\Handler\ContactHandler::class)->setName('contact'); |
|
28
|
|
|
* |
|
29
|
|
|
* or: |
|
30
|
|
|
* |
|
31
|
|
|
* $app->route( |
|
32
|
|
|
* '/contact', |
|
33
|
|
|
* App\Handler\ContactHandler::class, |
|
34
|
|
|
* Mezzio\Router\Route::HTTP_METHOD_ANY, |
|
35
|
|
|
* 'contact' |
|
36
|
|
|
* ); |
|
37
|
|
|
*/ |
|
38
|
|
|
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void { |
|
|
|
|
|
|
39
|
|
|
$app->post('/graphql', [ |
|
40
|
|
|
Ecodev\Felix\Middleware\SignedQueryMiddleware::class, |
|
41
|
|
|
\Application\Middleware\PatchGraphQlQueriesMiddleware::class, |
|
42
|
|
|
BodyParamsMiddleware::class, |
|
43
|
|
|
UploadMiddleware::class, |
|
44
|
|
|
GraphQLHandler::class, |
|
45
|
|
|
], 'graphql'); |
|
46
|
|
|
|
|
47
|
|
|
$app->get('/api/image/{id:\d+}[/{maxHeight:\d+}]', [ |
|
48
|
|
|
Ecodev\Felix\Handler\ImageHandler::class, |
|
49
|
|
|
], 'image'); |
|
50
|
|
|
|
|
51
|
|
|
$app->get('/api/accounting-document/{id:\d+}', [ |
|
52
|
|
|
\Application\Handler\AccountingDocumentHandler::class, |
|
53
|
|
|
], 'accounting-document'); |
|
54
|
|
|
|
|
55
|
|
|
$app->post('/api/datatrans', [ |
|
56
|
|
|
BodyParamsMiddleware::class, |
|
57
|
|
|
\Application\Handler\DatatransHandler::class, |
|
58
|
|
|
], 'datatrans'); |
|
59
|
|
|
}; |
|
60
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.