1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
/** |
4
|
|
|
* /src/Controller/v1/Localization/TimezoneController.php |
5
|
|
|
* |
6
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace App\Controller\v1\Localization; |
10
|
|
|
|
11
|
|
|
use App\Service\Localization; |
|
|
|
|
12
|
|
|
use OpenApi\Attributes as OA; |
13
|
|
|
use OpenApi\Attributes\JsonContent; |
14
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
16
|
|
|
use Symfony\Component\HttpKernel\Attribute\AsController; |
17
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class TimezoneController |
21
|
|
|
* |
22
|
|
|
* @package App\Controller\v1\Localization |
23
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
#[AsController] |
26
|
|
|
#[OA\Tag(name: 'Localization')] |
27
|
|
|
class TimeZoneController |
28
|
|
|
{ |
29
|
4 |
|
public function __construct( |
30
|
|
|
private readonly Localization $localization, |
31
|
|
|
) { |
32
|
4 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Endpoint action to get list of supported timezones. This is for use to |
36
|
|
|
* choose what timezone your frontend application can use within its date, |
37
|
|
|
* time, datetime, etc. formatting. |
38
|
|
|
*/ |
39
|
4 |
|
#[Route( |
40
|
|
|
path: '/v1/localization/timezone', |
41
|
|
|
methods: [Request::METHOD_GET], |
42
|
|
|
)] |
43
|
|
|
#[OA\Response( |
44
|
|
|
response: 200, |
45
|
|
|
description: 'List of timezone objects.', |
46
|
|
|
content: new JsonContent( |
47
|
|
|
type: 'array', |
48
|
|
|
items: new OA\Items( |
49
|
|
|
properties: [ |
50
|
|
|
new OA\Property( |
51
|
|
|
property: 'timezone', |
52
|
|
|
description: 'Africa, America, Antarctica, Arctic, Asia, Atlantic, Australia, Europe, ' . |
53
|
|
|
'Indian,Pacific,UTC.', |
54
|
|
|
type: 'string', |
55
|
|
|
example: 'Europe', |
56
|
|
|
), |
57
|
|
|
new OA\Property( |
58
|
|
|
property: 'identifier', |
59
|
|
|
description: 'Timezone identifier that you can use with other libraries.', |
60
|
|
|
type: 'string', |
61
|
|
|
example: 'Europe/Helsinki', |
62
|
|
|
), |
63
|
|
|
new OA\Property( |
64
|
|
|
property: 'offset', |
65
|
|
|
description: 'GMT offset of identifier.', |
66
|
|
|
type: 'string', |
67
|
|
|
example: 'GMT+2:00', |
68
|
|
|
), |
69
|
|
|
new OA\Property( |
70
|
|
|
property: 'value', |
71
|
|
|
description: 'User friendly value of identifier value eg. `_` characters are replaced ' . |
72
|
|
|
'by space.', |
73
|
|
|
type: 'string', |
74
|
|
|
example: 'Europe/Helsinki', |
75
|
|
|
), |
76
|
|
|
], |
77
|
|
|
type: 'object' |
78
|
|
|
), |
79
|
|
|
example: [ |
80
|
|
|
'timezone' => 'Europe', |
81
|
|
|
'identifier' => 'Europe/Helsinki', |
82
|
|
|
'offset' => 'GMT+2:00', |
83
|
|
|
'value' => 'Europe/Helsinki', |
84
|
|
|
], |
85
|
|
|
), |
86
|
|
|
)] |
87
|
|
|
public function __invoke(): JsonResponse |
88
|
|
|
{ |
89
|
4 |
|
return new JsonResponse($this->localization->getTimezones()); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths