JControllerLegacy implements a task map used by JControllerLegacy::execute to enable routing of the task to a method defined by a derivative class of JControllerLegacy such as JControllerAdmin and JControllerForm or their descendant classes.
Populating the Task map
The task map is populated by reference to the relative complementary public methods of the derivative class compared to JControllerLegacy. The public methods of the derivative class are secured using ReflectionClass::getMethods(ReflectionMethod::IS_PUBLIC) whereas the set of public methods of JControllerLegacy is determined more widely using the PHP API function get_class_methods. The resultant task map contains all of the public functions of the derivative class excluding any functions of the same name (irrespective of signature or parameter list) as JControllerLegacy.
JControllerLegacy::__construct($config = array())
JControllerLegacy::__construct is the constructor or parent constructor for an instance of the JControllerLegacy class.
JControllerLegacy::createView($name, $prefix = '', $type = '', $config = array())
The JControllerLegacy::createView method searchs for and, if found, loads a JViewLegacy object given by the catenated values of the optional prefix, $prefix and the name, $name.
- construct the JViewLegacy class definition file name using JControllerLegacy::createFileName according to the pattern, converted to lower case as follows: <$name>/view.<$type>.php; for example "view.html.php";
- search for the class definition file using JPath::find function and the path list provided by JControllerLegacy::$paths['view']; and
- if the class definition is found, load the class definition and instantiate a new instance of the JViewLegacy class.
Where a call is made to createView and the file name for the view is resolved using JControllerLegacy::createFileName, the path and file name generated is converted to lower case. Accordingly, a HTML view with the name 'DocumentList' is accessed from the directory 'documentlist/view.html.php'; this behaviour may create cross-platform issues depending on whether the underlying filesystem is case sensitive or case insensitive.
JControllerLegacy::getView($name = '', $type = '', $prefix = '', $config = array())
The JControllerLegacy::getView method returns a reference to current JViewLegacy object associated with the JControllerLegacy instance, or the named JViewLegacy instance which is loaded using JControllerLegacy::createView by reference to the provided, or default values of $name and $prefix which are as follows –
$name – the name of the controller, using JControllerLegacy::getName();
$prefix – the prefix of the view comprising the name of the controller provided by JControllerLegacy::getName() catenated with 'View'.
- if a redirection URL has not been assigned to JControllerLegacy::$redirect, return false;
- otherwise –
- enqueue both a redirection message and message type to the application message queue using JApplicationCms<JApplicationWeb<JApplicationBase::enqueueMessage($message, $type);
- execute JApplicationCms<JApplicationWeb<JApplicationBase::redirect($url, $moved [false]) which, in turn –
- stores the contents of the application message queue provided by JApplicationCms<JApplicationWeb<JApplicationBase::$_messageQueue to the global JSession object; and
- makes a call to JApplicationWeb<JApplicationBase::redirect($url, $moved [false]) which –
- converts relative URLs to absolute URL references and performs basic checks on the resultant URL to ensure that it does not violate the HTTP protocol;
- if the HTTP protocol headers have been sent to the client or the user agent is Microsoft Internet Explorer (JApplicationWebClient::TRIDENT), injects a redirection script into the output;
- otherwise, output a HTTP 1.1 '301 Moved permanently', or a '303 See other' and the relevant URL to the client;
- close the application by calling JApplicationBase::close($code ) which calls the PHP function exit($code) to terminate the application;
- impliedly, by virtue of the call to exit($code), the session_write_close() function is called to serialize the session data to the persistent store.