Summary Files Commits Branches @commit @diff @stats
path: root / src / controllers / BaseController.php
blob: 412cf25b5b9fccec441fab95ba1b7d0c5154031d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
class BaseController {
	/**
	 * Calls the get, post, put or delete static methods, depending on the server request method ($_SERVER['REQUEST_METHOD'])
	 * **By default** all requests that are not POST, PUT or DELETE execute the GET request method
	 */
	public static function invoke() {
		switch ($_SERVER['REQUEST_METHOD']) {
			case 'POST': 
				static::post();
				break;
			case 'PUT':
				static::put();
				break;
			case 'DELETE':
				static::delete();
				break;
			default:
				static::get();
				break;
		}
	}

	protected static function get() {
		echo 'GET method not implemented!';
	}

	protected static function post() {
		echo 'POST method not implemented!';
	}

	protected static function put() {
		echo 'PUT method not implemented!';
	}

	protected static function delete() {
		echo 'DELETE method not implemented!';
	}
}