PHP Class FOF30\Controller\DataController

Inheritance: extends Controller
Afficher le fichier Open project: akeeba/fof Class Usage Examples

Protected Properties

Свойство Type Description
$cacheParams false | array Variables that should be taken in account while working with the cache. You can set them in Controller constructor or inside onBefore* methods
$cacheableTasks array The tasks for which caching should be enabled by default
$defaultsForAdd array An indexed array of default values for the add task. Since the add task resets the model you can't set these values directly to the model. Instead, the defaultsForAdd values will be fed to model's bind() after it's reset and before the session-stored item data is bound to the model object.
$hasForm boolean Do we have a valid XML form?
$taskPrivileges array You can use the notation '@task' which means 'apply the same privileges as "task"'. If you create a reference back to yourself (e.g. 'mytask' => array('@mytask')) it will return TRUE.

Méthodes publiques

Méthode Description
__construct ( Container $container, array $config = [] ) Public constructor of the Controller class. You can pass the following variables in the $config array, on top of what you already have in the base Controller class:
add ( ) : void Single record add. The form layout is used to present a blank page.
apply ( ) : void Save the incoming data and then return to the Edit task
archive ( ) : void Archive (set enabled = 2) an item.
browse ( ) : void Implements a default browse task, i.e. read a bunch of records and send them to the browser.
cancel ( ) : void Cancel the edit, check in the record and return to the Browse task
checkin ( ) : void Check in (unlock) items
copy ( ) : void Duplicates selected items
edit ( ) : void Single record edit. The ID set in the request is passed to the model, then the form layout is used to edit the result.
execute ( string $task ) : null | boolean Executes a given controller task. The onBefore and onAfter methods are called automatically if they exist.
forceRemove ( ) : void Deletes the selected item(s). Unlike remove() this method will force delete the record (completely removed from database)
getIDsFromRequest ( DataModel &$model, boolean $loadRecord = true ) : array Gets the list of IDs from the request data
getItemidURLSuffix ( ) : string Gets a URL suffix with the Itemid parameter. If it's not the front-end of the site, or if there is no Itemid set it returns an empty string.
getModel ( string $name = null, array $config = [] ) : DataModel Returns a named Model object. Makes sure that the Model is a database-aware model, throwing an exception otherwise, when $name is null.
getView ( string $name = null, array $config = [] ) : View Returns a named View object
loadhistory ( ) : boolean Method to load a row from version history
orderdown ( ) : void Moves selected items one position down the ordering list
orderup ( ) : void Moves selected items one position up the ordering list
publish ( ) : void Publish (set enabled = 1) an item.
read ( ) : void Single record read. The id set in the request is passed to the model and then the item layout is used to render the result.
remove ( ) : void Delete or trash selected item(s). The model's softDelete flag determines if the items should be trashed (enabled state changed to -2) or deleted (completely removed from database)
save ( ) : void Save the incoming data and then return to the Browse task
savenew ( ) : boolean Save the incoming data and then return to the Add task
saveorder ( ) : void Saves the order of the items
trash ( ) : void Trash (set enabled = -2) an item.
unpublish ( ) : void Unpublish (set enabled = 0) an item.

Méthodes protégées

Méthode Description
applySave ( ) : boolean Common method to handle apply and save tasks
checkACL ( string $area ) : boolean Checks if the current user has enough privileges for the requested ACL area. This overridden method supports asset tracking as well.
deleteOrTrash ( $forceDelete = false )
getACLForApplySave ( ) : boolean | string Gets the applicable ACL privilege for the apply and save tasks. The value returned is: - @add if the record's ID is empty / record doesn't exist - True if the ACL privilege of the edit task (@edit) is allowed - @editown if the owner of the record (field user_id, userid or user) is the same as the logged in user - False if the record is not owned by the logged in user and the user doesn't have the @edit privilege
getCrudTask ( ) : string Determines the CRUD task to use based on the view name and HTTP verb used in the request.
onAfterExecute ( string $task ) : boolean Deal with JSON format: no redirects needed

Method Details

__construct() public méthode

taskPrivileges array ACL privileges for each task cacheableTasks array The cache-enabled tasks
public __construct ( Container $container, array $config = [] )
$container FOF30\Container\Container The application container
$config array The configuration array

add() public méthode

Single record add. The form layout is used to present a blank page.
public add ( ) : void
Résultat void

apply() public méthode

Save the incoming data and then return to the Edit task
public apply ( ) : void
Résultat void

applySave() protected méthode

Common method to handle apply and save tasks
protected applySave ( ) : boolean
Résultat boolean True on success

archive() public méthode

Archive (set enabled = 2) an item.
public archive ( ) : void
Résultat void

browse() public méthode

Implements a default browse task, i.e. read a bunch of records and send them to the browser.
public browse ( ) : void
Résultat void

cancel() public méthode

Cancel the edit, check in the record and return to the Browse task
public cancel ( ) : void
Résultat void

checkACL() protected méthode

Checks if the current user has enough privileges for the requested ACL area. This overridden method supports asset tracking as well.
protected checkACL ( string $area ) : boolean
$area string The ACL area, e.g. core.manage
Résultat boolean True if the user has the ACL privilege specified

checkin() public méthode

Check in (unlock) items
public checkin ( ) : void
Résultat void

copy() public méthode

Duplicates selected items
public copy ( ) : void
Résultat void

deleteOrTrash() protected méthode

protected deleteOrTrash ( $forceDelete = false )

edit() public méthode

Single record edit. The ID set in the request is passed to the model, then the form layout is used to edit the result.
public edit ( ) : void
Résultat void

execute() public méthode

If $task == 'default' we will determine the CRUD task to use based on the view name and HTTP verb in the request, overriding the routing.
public execute ( string $task ) : null | boolean
$task string The task to execute, e.g. "browse"
Résultat null | boolean False on execution failure

forceRemove() public méthode

Deletes the selected item(s). Unlike remove() this method will force delete the record (completely removed from database)
public forceRemove ( ) : void
Résultat void

getACLForApplySave() protected méthode

Gets the applicable ACL privilege for the apply and save tasks. The value returned is: - @add if the record's ID is empty / record doesn't exist - True if the ACL privilege of the edit task (@edit) is allowed - @editown if the owner of the record (field user_id, userid or user) is the same as the logged in user - False if the record is not owned by the logged in user and the user doesn't have the @edit privilege
protected getACLForApplySave ( ) : boolean | string
Résultat boolean | string

getCrudTask() protected méthode

Determines the CRUD task to use based on the view name and HTTP verb used in the request.
protected getCrudTask ( ) : string
Résultat string The CRUD task (browse, read, edit, delete)

getIDsFromRequest() public méthode

Gets the list of IDs from the request data
public getIDsFromRequest ( DataModel &$model, boolean $loadRecord = true ) : array
$model FOF30\Model\DataModel The model where the record will be loaded
$loadRecord boolean When true, the record matching the *first* ID found will be loaded into $model
Résultat array

getItemidURLSuffix() public méthode

Gets a URL suffix with the Itemid parameter. If it's not the front-end of the site, or if there is no Itemid set it returns an empty string.
public getItemidURLSuffix ( ) : string
Résultat string The &Itemid=123 URL suffix, or an empty string if Itemid is not applicable

getModel() public méthode

Returns a named Model object. Makes sure that the Model is a database-aware model, throwing an exception otherwise, when $name is null.
public getModel ( string $name = null, array $config = [] ) : DataModel
$name string The Model name. If null we'll use the modelName variable or, if it's empty, the same name as the Controller
$config array Configuration parameters to the Model. If skipped we will use $this->config
Résultat FOF30\Model\DataModel The instance of the Model known to this Controller

getView() public méthode

Returns a named View object
public getView ( string $name = null, array $config = [] ) : View
$name string The Model name. If null we'll use the modelName variable or, if it's empty, the same name as the Controller
$config array Configuration parameters to the Model. If skipped we will use $this->config
Résultat FOF30\View\View The instance of the Model known to this Controller

loadhistory() public méthode

Method to load a row from version history
Since: 2.2
public loadhistory ( ) : boolean
Résultat boolean True if the content history is reverted, false otherwise

onAfterExecute() protected méthode

Deal with JSON format: no redirects needed
protected onAfterExecute ( string $task ) : boolean
$task string The task being executed
Résultat boolean True if everything went well

orderdown() public méthode

Moves selected items one position down the ordering list
public orderdown ( ) : void
Résultat void

orderup() public méthode

Moves selected items one position up the ordering list
public orderup ( ) : void
Résultat void

publish() public méthode

Publish (set enabled = 1) an item.
public publish ( ) : void
Résultat void

read() public méthode

Single record read. The id set in the request is passed to the model and then the item layout is used to render the result.
public read ( ) : void
Résultat void

remove() public méthode

Delete or trash selected item(s). The model's softDelete flag determines if the items should be trashed (enabled state changed to -2) or deleted (completely removed from database)
public remove ( ) : void
Résultat void

save() public méthode

Save the incoming data and then return to the Browse task
public save ( ) : void
Résultat void

savenew() public méthode

Save the incoming data and then return to the Add task
public savenew ( ) : boolean
Résultat boolean

saveorder() public méthode

Saves the order of the items
public saveorder ( ) : void
Résultat void

trash() public méthode

Trash (set enabled = -2) an item.
public trash ( ) : void
Résultat void

unpublish() public méthode

Unpublish (set enabled = 0) an item.
public unpublish ( ) : void
Résultat void

Property Details

$cacheParams protected_oe property

Variables that should be taken in account while working with the cache. You can set them in Controller constructor or inside onBefore* methods
protected false|array $cacheParams
Résultat false | array

$cacheableTasks protected_oe property

The tasks for which caching should be enabled by default
protected array $cacheableTasks
Résultat array

$defaultsForAdd protected_oe property

An indexed array of default values for the add task. Since the add task resets the model you can't set these values directly to the model. Instead, the defaultsForAdd values will be fed to model's bind() after it's reset and before the session-stored item data is bound to the model object.
protected array $defaultsForAdd
Résultat array

$hasForm protected_oe property

Do we have a valid XML form?
protected bool $hasForm
Résultat boolean

$taskPrivileges protected_oe property

You can use the notation '@task' which means 'apply the same privileges as "task"'. If you create a reference back to yourself (e.g. 'mytask' => array('@mytask')) it will return TRUE.
protected array $taskPrivileges
Résultat array