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