aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Web/Controller.php
blob: 6384f24dfaf508ff6ddcc8d8fe3e013694f3f1e2 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

namespace Zotlabs\Web;

/**
 * Base controller class for Modules.
 *
 * Modules should extend this class, and override the methods needed. Emtpy
 * default implementations allow Modules to only override the methods they
 * need.
 *
 * The methods defined by this class is invoked in order:
 *
 *   - init()
 *   - post() -- only for POST requests
 *   - get()
 *
 * Modules which emit other serialisations besides HTML (XML,JSON, etc.) should
 * do so within the module `init` and/or `post` functions and then invoke
 * `killme()` to terminate further processing.
 */
abstract class Controller {

	/**
	 * Initialize request processing.
	 *
	 * This method is called before any other request processing, and
	 * regardless of the request method. The theme is not yet loaded when
	 * this method is invoked.
	 */
	public function init() {
	}

	/**
	 * Process POST requests.
	 *
	 * This method is called if the incoming request is a POST request. It is
	 * invoked after the theme has been loaded. This method should not normally
	 * render HTML output, as processing will fall through to the GET processing
	 * if this method completes without error or stopping processing in other
	 * ways.
	 */
	public function post() {
	}

	/**
	 * Process GET requests or the body part of POST requests.
	 *
	 * This method is called directly for GET requests, and immediately after the
	 * `post()` method for POST requests.
	 *
	 * It will return the module content as a HTML string.
	 *
	 * @return string HTML content for the module.
	 */
	public function get() {
		return '';
	}
}