1 | <?php |
||
41 | class BoardApiController extends ApiController { |
||
42 | |||
43 | private $boardService; |
||
44 | |||
45 | /** |
||
46 | * @param string $appName |
||
47 | * @param IRequest $request |
||
48 | * @param BoardService $service |
||
49 | * @param $userId |
||
50 | */ |
||
51 | public function __construct($appName, IRequest $request, BoardService $service, $userId) { |
||
56 | |||
57 | /** |
||
58 | * @NoAdminRequired |
||
59 | * @CORS |
||
60 | * @NoCSRFRequired |
||
61 | * |
||
62 | * Return all of the boards that the current user has access to. |
||
63 | * @throws StatusException |
||
64 | */ |
||
65 | public function index($details = null) { |
||
66 | $modified = $this->request->getHeader('If-Modified-Since'); |
||
67 | if ($modified === null || $modified === '') { |
||
68 | $boards = $this->boardService->findAll(0, $details); |
||
69 | } else { |
||
70 | $date = Util::parseHTTPDate($modified); |
||
71 | if (!$date) { |
||
72 | throw new StatusException('Invalid If-Modified-Since header provided.'); |
||
73 | } |
||
74 | $boards = $this->boardService->findAll($date->getTimestamp(), $details); |
||
75 | } |
||
76 | return new DataResponse($boards, HTTP::STATUS_OK); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @NoAdminRequired |
||
81 | * @CORS |
||
82 | * @NoCSRFRequired |
||
83 | * |
||
84 | * |
||
85 | * Return the board specified by $this->request->getParam('boardId'). |
||
86 | */ |
||
87 | public function get() { |
||
91 | |||
92 | /** |
||
93 | * @NoAdminRequired |
||
94 | * @CORS |
||
95 | * @NoCSRFRequired |
||
96 | * |
||
97 | * @params $title |
||
98 | * @params $color |
||
99 | * |
||
100 | * Create a board with the specified title and color. |
||
101 | */ |
||
102 | public function create($title, $color) { |
||
106 | |||
107 | /** |
||
108 | * @NoAdminRequired |
||
109 | * @CORS |
||
110 | * @NoCSRFRequired |
||
111 | * |
||
112 | * @params $title |
||
113 | * @params $color |
||
114 | * @params $archived |
||
115 | * |
||
116 | * Update a board with the specified boardId, title and color, and archived state. |
||
117 | */ |
||
118 | public function update($title, $color, $archived = false) { |
||
122 | |||
123 | /** |
||
124 | * @NoAdminRequired |
||
125 | * @CORS |
||
126 | * @NoCSRFRequired |
||
127 | * |
||
128 | * |
||
129 | * Delete the board specified by $boardId. Return the board that was deleted. |
||
130 | */ |
||
131 | public function delete() { |
||
135 | |||
136 | /** |
||
137 | * @NoAdminRequired |
||
138 | * @CORS |
||
139 | * @NoCSRFRequired |
||
140 | * |
||
141 | * |
||
142 | * Undo the deletion of the board specified by $boardId. |
||
143 | */ |
||
144 | public function undoDelete() { |
||
148 | |||
149 | /** |
||
150 | * @NoAdminRequired |
||
151 | * @CORS |
||
152 | * @NoCSRFRequired |
||
153 | */ |
||
154 | public function addAcl($boardId, $type, $participant, $permissionEdit, $permissionShare, $permissionManage) { |
||
158 | |||
159 | /** |
||
160 | * @NoAdminRequired |
||
161 | * @CORS |
||
162 | * @NoCSRFRequired |
||
163 | */ |
||
164 | public function updateAcl($aclId, $permissionEdit, $permissionShare, $permissionManage) { |
||
168 | |||
169 | /** |
||
170 | * @NoAdminRequired |
||
171 | * @CORS |
||
172 | * @NoCSRFRequired |
||
173 | */ |
||
174 | public function deleteAcl($aclId) { |
||
178 | |||
179 | } |
||
180 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: