|
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\Annotations as OA; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
15
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
16
|
|
|
use Throwable; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class TimezoneController |
|
20
|
|
|
* |
|
21
|
|
|
* @OA\Tag(name="Localization") |
|
22
|
|
|
* |
|
23
|
|
|
* @package App\Controller\v1\Localization |
|
24
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class TimeZoneController |
|
27
|
|
|
{ |
|
28
|
3 |
|
public function __construct( |
|
29
|
|
|
private Localization $localization, |
|
30
|
|
|
) { |
|
31
|
3 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Endpoint action to get list of supported timezones. This is for use to |
|
35
|
|
|
* choose what timezone your frontend application can use within its date, |
|
36
|
|
|
* time, datetime, etc. formatting. |
|
37
|
|
|
* |
|
38
|
|
|
* @OA\Response( |
|
39
|
|
|
* response=200, |
|
40
|
|
|
* description="List of timezone objects.", |
|
41
|
|
|
* @OA\Schema( |
|
42
|
|
|
* type="array", |
|
43
|
|
|
* @OA\Items( |
|
44
|
|
|
* type="object", |
|
45
|
|
|
* @OA\Property( |
|
46
|
|
|
* property="timezone", |
|
47
|
|
|
* type="string", |
|
48
|
|
|
* example="Europe", |
|
49
|
|
|
* description="Africa,America,Antarctica,Arctic,Asia,Atlantic,Australia,Europe,Indian,Pacific,UTC.", |
|
50
|
|
|
* ), |
|
51
|
|
|
* @OA\Property( |
|
52
|
|
|
* property="identier", |
|
53
|
|
|
* type="string", |
|
54
|
|
|
* example="Europe/Helsinki", |
|
55
|
|
|
* description="Timezone identifier that you can use with other librariers.", |
|
56
|
|
|
* ), |
|
57
|
|
|
* @OA\Property( |
|
58
|
|
|
* property="offset", |
|
59
|
|
|
* type="string", |
|
60
|
|
|
* example="GMT+2:00", |
|
61
|
|
|
* description="GMT offset of identifier.", |
|
62
|
|
|
* ), |
|
63
|
|
|
* @OA\Property( |
|
64
|
|
|
* property="value", |
|
65
|
|
|
* type="string", |
|
66
|
|
|
* example="Europe/Helsinki", |
|
67
|
|
|
* description="User friendly value of identifier value eg. '_' characters are replaced by space.", |
|
68
|
|
|
* ), |
|
69
|
|
|
* ), |
|
70
|
|
|
* ), |
|
71
|
|
|
* ) |
|
72
|
|
|
* |
|
73
|
|
|
* @throws Throwable |
|
74
|
|
|
*/ |
|
75
|
3 |
|
#[Route( |
|
76
|
|
|
path: '/v1/localization/timezone', |
|
77
|
|
|
methods: [Request::METHOD_GET], |
|
78
|
|
|
)] |
|
79
|
|
|
public function __invoke(): JsonResponse |
|
80
|
|
|
{ |
|
81
|
3 |
|
return new JsonResponse($this->localization->getTimezones()); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|