PHP Класс FOF30\Controller\DataController

Наследование: extends Controller
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

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() публичный Метод

Single record add. The form layout is used to present a blank page.
public add ( ) : void
Результат void

apply() публичный Метод

Save the incoming data and then return to the Edit task
public apply ( ) : void
Результат void

applySave() защищенный Метод

Common method to handle apply and save tasks
protected applySave ( ) : boolean
Результат boolean True on success

archive() публичный Метод

Archive (set enabled = 2) an item.
public archive ( ) : void
Результат void

browse() публичный Метод

Implements a default browse task, i.e. read a bunch of records and send them to the browser.
public browse ( ) : void
Результат void

cancel() публичный Метод

Cancel the edit, check in the record and return to the Browse task
public cancel ( ) : void
Результат void

checkACL() защищенный Метод

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
Результат boolean True if the user has the ACL privilege specified

checkin() публичный Метод

Check in (unlock) items
public checkin ( ) : void
Результат void

copy() публичный Метод

Duplicates selected items
public copy ( ) : void
Результат void

deleteOrTrash() защищенный Метод

protected deleteOrTrash ( $forceDelete = false )

edit() публичный Метод

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
Результат void

execute() публичный Метод

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"
Результат null | boolean False on execution failure

forceRemove() публичный Метод

Deletes the selected item(s). Unlike remove() this method will force delete the record (completely removed from database)
public forceRemove ( ) : void
Результат void

getACLForApplySave() защищенный Метод

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
Результат boolean | string

getCrudTask() защищенный Метод

Determines the CRUD task to use based on the view name and HTTP verb used in the request.
protected getCrudTask ( ) : string
Результат string The CRUD task (browse, read, edit, delete)

getIDsFromRequest() публичный Метод

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
Результат array

getItemidURLSuffix() публичный Метод

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
Результат string The &Itemid=123 URL suffix, or an empty string if Itemid is not applicable

getModel() публичный Метод

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
Результат FOF30\Model\DataModel The instance of the Model known to this Controller

getView() публичный Метод

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
Результат FOF30\View\View The instance of the Model known to this Controller

loadhistory() публичный Метод

Method to load a row from version history
С версии: 2.2
public loadhistory ( ) : boolean
Результат boolean True if the content history is reverted, false otherwise

onAfterExecute() защищенный Метод

Deal with JSON format: no redirects needed
protected onAfterExecute ( string $task ) : boolean
$task string The task being executed
Результат boolean True if everything went well

orderdown() публичный Метод

Moves selected items one position down the ordering list
public orderdown ( ) : void
Результат void

orderup() публичный Метод

Moves selected items one position up the ordering list
public orderup ( ) : void
Результат void

publish() публичный Метод

Publish (set enabled = 1) an item.
public publish ( ) : void
Результат void

read() публичный Метод

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
Результат void

remove() публичный Метод

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
Результат void

save() публичный Метод

Save the incoming data and then return to the Browse task
public save ( ) : void
Результат void

savenew() публичный Метод

Save the incoming data and then return to the Add task
public savenew ( ) : boolean
Результат boolean

saveorder() публичный Метод

Saves the order of the items
public saveorder ( ) : void
Результат void

trash() публичный Метод

Trash (set enabled = -2) an item.
public trash ( ) : void
Результат void

unpublish() публичный Метод

Unpublish (set enabled = 0) an item.
public unpublish ( ) : void
Результат void

Описание свойств

$cacheParams защищенное свойство

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
Результат false | array

$cacheableTasks защищенное свойство

The tasks for which caching should be enabled by default
protected array $cacheableTasks
Результат array

$defaultsForAdd защищенное свойство

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
Результат array

$hasForm защищенное свойство

Do we have a valid XML form?
protected bool $hasForm
Результат boolean

$taskPrivileges защищенное свойство

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
Результат array