|
@@ -74,7 +74,7 @@ discard block |
|
|
block discarded – undo |
|
74
|
74
|
'factories' => [ |
|
75
|
75
|
\Zend\Expressive\Helper\UrlHelper::class => \Zend\Expressive\Helper\UrlHelperFactory::class, |
|
76
|
76
|
|
|
77
|
|
- \Phrest\Application::SERVICE_LOGGER => function (\Interop\Container\ContainerInterface $container) use ($logger, $monologHandler, $monologProcessor) { |
|
|
77
|
+ \Phrest\Application::SERVICE_LOGGER => function(\Interop\Container\ContainerInterface $container) use ($logger, $monologHandler, $monologProcessor) { |
|
78
|
78
|
$handlers = []; |
|
79
|
79
|
foreach ($monologHandler as $handler) { |
|
80
|
80
|
$handlers[] = $container->get($handler); |
|
@@ -86,11 +86,11 @@ discard block |
|
|
block discarded – undo |
|
86
|
86
|
return $logger; |
|
87
|
87
|
}, |
|
88
|
88
|
|
|
89
|
|
- \Phrest\Application::SERVICE_SWAGGER => function () use ($cache, $swaggerScanDirectory) { |
|
|
89
|
+ \Phrest\Application::SERVICE_SWAGGER => function() use ($cache, $swaggerScanDirectory) { |
|
90
|
90
|
return new \Phrest\Swagger($cache, $swaggerScanDirectory); |
|
91
|
91
|
}, |
|
92
|
92
|
|
|
93
|
|
- \Phrest\Application::SERVICE_HATEOAS => function (\Interop\Container\ContainerInterface $container) use ($enableCache, $cacheDirectory) { |
|
|
93
|
+ \Phrest\Application::SERVICE_HATEOAS => function(\Interop\Container\ContainerInterface $container) use ($enableCache, $cacheDirectory) { |
|
94
|
94
|
/** @var \Zend\Expressive\Router\RouterInterface $router */ |
|
95
|
95
|
$router = $container->get(\Zend\Expressive\Router\RouterInterface::class); |
|
96
|
96
|
|
|
@@ -106,7 +106,7 @@ discard block |
|
|
block discarded – undo |
|
106
|
106
|
$hateoasBuilder->setUrlGenerator( |
|
107
|
107
|
null, |
|
108
|
108
|
new \Hateoas\UrlGenerator\CallableUrlGenerator( |
|
109
|
|
- function ($route, array $parameters, $absolute) use ($router, $serverUrlHelper) { |
|
|
109
|
+ function($route, array $parameters, $absolute) use ($router, $serverUrlHelper) { |
|
110
|
110
|
$uri = $router->generateUri($route, $parameters); |
|
111
|
111
|
if ($absolute) { |
|
112
|
112
|
return $serverUrlHelper($uri); |
|
@@ -118,11 +118,11 @@ discard block |
|
|
block discarded – undo |
|
118
|
118
|
return $hateoasBuilder->build(); |
|
119
|
119
|
}, |
|
120
|
120
|
|
|
121
|
|
- \Phrest\Application::ACTION_SWAGGER => function (\Interop\Container\ContainerInterface $container) { |
|
|
121
|
+ \Phrest\Application::ACTION_SWAGGER => function(\Interop\Container\ContainerInterface $container) { |
|
122
|
122
|
return new \Phrest\API\Action\Swagger($container->get(\Phrest\Application::SERVICE_SWAGGER)); |
|
123
|
123
|
}, |
|
124
|
124
|
|
|
125
|
|
- \Phrest\Application::ACTION_ERROR_CODES => function (\Interop\Container\ContainerInterface $container) use ($cache, $errorCodes) { |
|
|
125
|
+ \Phrest\Application::ACTION_ERROR_CODES => function(\Interop\Container\ContainerInterface $container) use ($cache, $errorCodes) { |
|
126
|
126
|
if ($errorCodes) { |
|
127
|
127
|
$errorCodesInstance = $container->get($errorCodes); |
|
128
|
128
|
} else { |
|
@@ -131,13 +131,13 @@ discard block |
|
|
block discarded – undo |
|
131
|
131
|
return new \Phrest\API\Action\ErrorCodes($cache, $errorCodesInstance); |
|
132
|
132
|
}, |
|
133
|
133
|
|
|
134
|
|
- \Phrest\Application::SERVICE_HATEOAS_RESPONSE_GENERATOR => function (\Interop\Container\ContainerInterface $container) { |
|
|
134
|
+ \Phrest\Application::SERVICE_HATEOAS_RESPONSE_GENERATOR => function(\Interop\Container\ContainerInterface $container) { |
|
135
|
135
|
return new \Phrest\API\HateoasResponseGenerator( |
|
136
|
136
|
$container->get(\Phrest\Application::SERVICE_HATEOAS) |
|
137
|
137
|
); |
|
138
|
138
|
}, |
|
139
|
139
|
|
|
140
|
|
- \Phrest\Application::SERVICE_REQUEST_SWAGGER_VALIDATOR => function (\Interop\Container\ContainerInterface $container) { |
|
|
140
|
+ \Phrest\Application::SERVICE_REQUEST_SWAGGER_VALIDATOR => function(\Interop\Container\ContainerInterface $container) { |
|
141
|
141
|
/** @var \Phrest\Swagger $swagger */ |
|
142
|
142
|
$swagger = $container->get(\Phrest\Application::SERVICE_SWAGGER); |
|
143
|
143
|
$jsonValidator = new \JsonSchema\Validator( |
|
@@ -146,11 +146,11 @@ discard block |
|
|
block discarded – undo |
|
146
|
146
|
return new \Phrest\API\RequestSwaggerValidator($swagger, $jsonValidator); |
|
147
|
147
|
}, |
|
148
|
148
|
|
|
149
|
|
- \Phrest\Application::SERVICE_ROUTER => function () { |
|
|
149
|
+ \Phrest\Application::SERVICE_ROUTER => function() { |
|
150
|
150
|
return new \Zend\Expressive\Router\FastRouteRouter(); |
|
151
|
151
|
}, |
|
152
|
152
|
|
|
153
|
|
- \Zend\Expressive\Router\RouterInterface::class => function (\Interop\Container\ContainerInterface $container) { |
|
|
153
|
+ \Zend\Expressive\Router\RouterInterface::class => function(\Interop\Container\ContainerInterface $container) { |
|
154
|
154
|
return $container->get(\Phrest\Application::SERVICE_ROUTER); |
|
155
|
155
|
} |
|
156
|
156
|
], |
|
@@ -158,21 +158,21 @@ discard block |
|
|
block discarded – undo |
|
158
|
158
|
\Zend\Expressive\Helper\ServerUrlHelper::class => \Zend\Expressive\Helper\ServerUrlHelper::class |
|
159
|
159
|
], |
|
160
|
160
|
'initializers' => [ |
|
161
|
|
- \Psr\Log\LoggerAwareInterface::class => function (\Interop\Container\ContainerInterface $container, $service) { |
|
|
161
|
+ \Psr\Log\LoggerAwareInterface::class => function(\Interop\Container\ContainerInterface $container, $service) { |
|
162
|
162
|
if ($service instanceof \Psr\Log\LoggerAwareInterface) { |
|
163
|
163
|
$service->setLogger( |
|
164
|
164
|
$container->get(\Phrest\Application::SERVICE_LOGGER) |
|
165
|
165
|
); |
|
166
|
166
|
} |
|
167
|
167
|
}, |
|
168
|
|
- API\RequestSwaggerValidatorAwareInterface::class => function (\Interop\Container\ContainerInterface $container, $service) { |
|
|
168
|
+ API\RequestSwaggerValidatorAwareInterface::class => function(\Interop\Container\ContainerInterface $container, $service) { |
|
169
|
169
|
if ($service instanceof API\RequestSwaggerValidatorAwareInterface) { |
|
170
|
170
|
$service->setRequestSwaggerValidator( |
|
171
|
171
|
$container->get(\Phrest\Application::SERVICE_REQUEST_SWAGGER_VALIDATOR) |
|
172
|
172
|
); |
|
173
|
173
|
} |
|
174
|
174
|
}, |
|
175
|
|
- API\HateoasResponseGeneratorAwareInterface::class => function (\Interop\Container\ContainerInterface $container, $service) { |
|
|
175
|
+ API\HateoasResponseGeneratorAwareInterface::class => function(\Interop\Container\ContainerInterface $container, $service) { |
|
176
|
176
|
if ($service instanceof API\HateoasResponseGeneratorAwareInterface) { |
|
177
|
177
|
$service->setHateoasResponseGenerator( |
|
178
|
178
|
$container->get(\Phrest\Application::SERVICE_HATEOAS_RESPONSE_GENERATOR) |
|
@@ -206,7 +206,7 @@ discard block |
|
|
block discarded – undo |
|
206
|
206
|
$app->run($request); |
|
207
|
207
|
} |
|
208
|
208
|
|
|
209
|
|
- static function createCache(bool $enableCache, ?string $cacheDirectory): \Zend\Cache\Storage\StorageInterface |
|
|
209
|
+ static function createCache(bool $enableCache, ?string $cacheDirectory) : \Zend\Cache\Storage\StorageInterface |
|
210
|
210
|
{ |
|
211
|
211
|
$cache = new \Zend\Cache\Storage\Adapter\BlackHole(); |
|
212
|
212
|
if ($enableCache) { |