Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| BaseController | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
6 | |
100.00% |
1 / 1 |
| __invoke | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| readResponse | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| getSchemaConstraintList | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use Psr\Http\Message\RequestInterface; |
| 11 | use Psr\Http\Message\ResponseInterface; |
| 12 | |
| 13 | /** |
| 14 | * @SuppressWarnings(NumberOfChildren) |
| 15 | * |
| 16 | */ |
| 17 | abstract class BaseController extends \BO\Slim\Controller |
| 18 | { |
| 19 | public function __invoke(RequestInterface $request, ResponseInterface $response, array $args) |
| 20 | { |
| 21 | $request = $this->initRequest($request); |
| 22 | $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0'); |
| 23 | return $this->readResponse($request, $noCacheResponse, $args); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @codeCoverageIgnore |
| 28 | * |
| 29 | */ |
| 30 | public function readResponse(RequestInterface $request, ResponseInterface $response, array $args) |
| 31 | { |
| 32 | return parent::__invoke($request, $response, $args); |
| 33 | } |
| 34 | |
| 35 | public function getSchemaConstraintList($schema) |
| 36 | { |
| 37 | $list = []; |
| 38 | $locale = \App::$language->getLocale(); |
| 39 | foreach ($schema->properties as $key => $property) { |
| 40 | if (isset($property['x-locale'])) { |
| 41 | $constraints = $property['x-locale'][$locale]; |
| 42 | if ($constraints) { |
| 43 | $list[$key]['description'] = $constraints['messages']; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | return $list; |
| 48 | } |
| 49 | } |