1 | <?php |
||
2 | |||
3 | namespace App\Controller; |
||
4 | |||
5 | use DateTime; |
||
6 | use OpenApi; |
||
7 | use Zend\Diactoros\Response; |
||
8 | |||
9 | /** |
||
10 | * @OA\OpenApi( |
||
11 | * schemes={"https"}, |
||
12 | * host="awesome.scot", |
||
13 | * basePath="/", |
||
14 | * @OA\Info( |
||
15 | * version="1.0.0", |
||
16 | * title="BONE MVC API", |
||
17 | * description="This be a swashbucklin' API." |
||
18 | * ), |
||
19 | * @OA\ExternalDocumentation( |
||
20 | * description="By delboy1978uk", |
||
21 | * url="https://github.com/delboy1978uk" |
||
22 | * ), |
||
23 | * @OA\SecurityScheme( |
||
24 | * securityDefinition="oauth2", |
||
25 | * type="oauth2", |
||
26 | * description="OAuth2 Connectivity", |
||
27 | * flow="implicit", |
||
28 | * authorizationUrl="https://awesome.scot/oauth2/authorize", |
||
29 | * tokenUrl="https://awesome.scot/oauth2/token", |
||
30 | * scopes={ |
||
31 | * admin="Admin scope.", |
||
32 | * test_scope="Test scope." |
||
33 | * } |
||
34 | * ) |
||
35 | * ) |
||
36 | * |
||
37 | */ |
||
38 | class IndexController extends BaseController |
||
39 | { |
||
40 | 2 | public function indexAction() |
|
41 | { |
||
42 | 2 | $this->enableLayout(); |
|
43 | 2 | $this->enableView(); |
|
44 | 2 | } |
|
45 | |||
46 | /** |
||
47 | * Check basic connectivity. Returns a timestamp. |
||
48 | * @OA\Get( |
||
49 | * path="/ping", |
||
50 | * tags={"status"}, |
||
51 | * @OA\Response(response="200", description="Sends a response with the time") |
||
52 | * ) |
||
53 | * |
||
54 | */ |
||
55 | 2 | public function pingAction() |
|
56 | { |
||
57 | 2 | $date = new DateTime(); |
|
58 | 2 | $this->sendJsonResponse(['pong' => $date->format('Y-m-d H:i:s')]); |
|
59 | 2 | } |
|
60 | |||
61 | /** |
||
62 | * @return Response |
||
63 | */ |
||
64 | public function apiAction() |
||
65 | { |
||
66 | $swagger = OpenApi\scan(APPLICATION_PATH.'/src')->toJson(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
67 | $response = new Response(); |
||
68 | $response = $response->withHeader('Content-Type', 'application/json'); |
||
69 | $response->getBody()->write($swagger); |
||
70 | return $response; |
||
71 | } |
||
72 | |||
73 | 1 | public function fakeClientCallbackAction() |
|
74 | { |
||
75 | 1 | $this->sendJsonResponse($this->getParams()); |
|
76 | 1 | } |
|
77 | |||
78 | /** |
||
79 | * temporary development view for writing email templates |
||
80 | * @return Response |
||
81 | */ |
||
82 | public function emailAction() |
||
83 | { |
||
84 | $reg = $this->getViewEngine()->render('emails/user_registration/user_registration', [ |
||
85 | 'siteUrl' => $this->getServerEnvironment()->getSiteURL(), |
||
86 | 'activationLink' => '/user/activate/[email protected]/dhfdhfddhfdh', |
||
87 | ]); |
||
88 | $response = new Response(); |
||
89 | $response->getBody()->write($reg); |
||
90 | return $response; |
||
91 | } |
||
92 | } |
||
93 |