1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Vitaly Iegorov <[email protected]>. |
4
|
|
|
* on 23.02.16 at 16:22 |
5
|
|
|
*/ |
6
|
|
|
namespace samsoncms\api\generator; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* API Controller generation |
10
|
|
|
* @package samsoncms\api\generator |
11
|
|
|
*/ |
12
|
|
|
class API |
13
|
|
|
{ |
14
|
|
|
public function __construct() |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* GET http://www.example.com/customers/ |
21
|
|
|
*/ |
22
|
|
|
public function generateListEntity() |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* One-to-many relation |
29
|
|
|
* GET http://www.example.com/customers/{parentID}/{relatedEntityName} - 200 |
30
|
|
|
*/ |
31
|
|
|
public function generateListRelatedEntity() |
32
|
|
|
{ |
33
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* POST http://www.example.com/customers/ - 201, redirect to /customers/{createdID} |
38
|
|
|
* POST http://www.example.com/customers/ - 204, if content is wrong |
39
|
|
|
* POST http://www.example.com/customers/{ID} - 404, if does not exists |
40
|
|
|
* POST http://www.example.com/customers/{ID} - 409 if already exists |
41
|
|
|
*/ |
42
|
|
|
public function generateCreateEntity() |
43
|
|
|
{ |
44
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* POST http://www.example.com/customers/{parentID}/{relatedEntityName} - 201, redirect to /customers/{parentID} |
49
|
|
|
* POST http://www.example.com/customers/{parentID}/{relatedEntityName} - 404, if does not exists |
50
|
|
|
*/ |
51
|
|
|
public function generateCreateRelatedEntity() |
52
|
|
|
{ |
53
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* GET http://www.example.com/customers/{customerID} |
58
|
|
|
*/ |
59
|
|
|
public function generateReadEntity() |
60
|
|
|
{ |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* PUT http://www.example.com/customers/{customerID} - 200, if ok |
66
|
|
|
* PUT http://www.example.com/customers/{customerID} - 204, if content is wrong |
67
|
|
|
* PUT http://www.example.com/customers/{customerID} - 404, if id not found |
68
|
|
|
*/ |
69
|
|
|
public function generateUpdateEntity() |
70
|
|
|
{ |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* DELETE http://www.example.com/customers/{customerID} - 200, if ok |
76
|
|
|
* DELETE http://www.example.com/customers/{customerID} - 404, if id not found |
77
|
|
|
*/ |
78
|
|
|
public function generateDeleteEntity() |
79
|
|
|
{ |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|