Actions

API16

JController/execute

From Joomla! Documentation

< API16:JController
Revision as of 17:35, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Execute a task by triggering a method in the derived class.

[Edit Descripton]

Description:JController/execute

Syntax

execute($task)
Parameter Name Default Value Description
$task The task to perform. If no matching task is found, the '__default' task is executed, if defined.

Returns

mixed|false The value returned by the called method, false in error case.

Defined in

libraries/joomla/application/component/controller.php

Importing

jimport( 'joomla.application.component.controller' );

Source Body

function execute($task)
{
        $this->_task = $task;
 
        $task = strtolower($task);
        if (isset($this->_taskMap[$task])) {
                $doTask = $this->_taskMap[$task];
        } elseif (isset($this->_taskMap['__default'])) {
                $doTask = $this->_taskMap['__default'];
        } else {
                return JError::raiseError(404, JText::_('Task ['.$task.'] not found'));
        }
 
        // Record the actual task being fired
        $this->_doTask = $doTask;
 
        // Make sure we have access
        if ($this->authorize($doTask)) {
                $retval = $this->$doTask();
                return $retval;
        } else {
                return JError::raiseError(403, JText::_('ACCESS_FORBIDDEN'));
        }
 
}

[Edit See Also] SeeAlso:JController/execute

Examples

<CodeExamplesForm />