This repository has been archived by the owner on Nov 26, 2017. It is now read-only.
/
jcontrollerbase.xml
69 lines (59 loc) · 2.29 KB
/
jcontrollerbase.xml
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
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "../../Developer_Manual.ent">
%BOOK_ENTITIES;
]>
<section>
<title>JControllerBase</title>
<section>
<title>Construction</title>
<para>The constructor for <classname>JControllerBase</classname> takes an optional <classname>JInput</classname> object and an
optional <classname>JApplciationBase</classname> object. If either is omitted, the constructor defers to the protected
loadInput and loadApplication methods respectively. These methods can be overriden in derived classes if the default
application and request input is not appropriate.</para>
</section>
<section>
<title>Usage</title>
<para>The <classname>JControllerBase</classname> class is abstract so cannot be used directly. The derived class must
implement the execute method to satisfy the interface requirements. Note that the execute method no longer takes a "task"
argument as each controller class. Multi-task controllers are still possible but not recommended. Each controller class should
do just one sort of 'thing', just as saving, deleting, checking in, checking out and so on. However, controllers, or even
models and views, have the liberty of invoking other controllers to allow for HMVC architectures.</para>
<example>
<title>Example controller</title>
<programlisting> /**
* My custom controller.
*
* @package Examples
*
* @since 12.1
*/
class MyController extends JControllerBase
{
/**
* Method to execute the controller.
*
* @return void
*
* @since 12.1
* @throws RuntimeException
*/
public function execute()
{
echo time();
}
}
// Instantiate the controller.
$controller = new MyController;
// Print the time.
$controller->execute();</programlisting>
</example>
</section>
<section>
<title>Serialization</title>
<para>The <classname>JControllerBase</classname> class implements <interfacename>Serializable</interfacename>. When
serializing, only the input property is serialized. When unserializing, the input variable is unserialized and the internal
application property is loaded at runtime.</para>
</section>
</section>