Detailed Description
BatchController is used to process complex, longer running actions, that need to be divided into several requests to overcome resource limits and provide progress information to the user.
Conceptionally the process is divided into subactions (work packages), that are called sequentially. Depending on the progress, the controller sets different actions on the response as result of one execution.
BatchController only sets up the infrastructure, the concrete process is defined by creating a subclass and implementing the abstract methods (mainly BatchController::getWorkPackage()).
The controller supports the following actions:
Parameter | Description |
---|---|
in oneCall | Boolean whether to accomplish the task in one call (optional, default: false) |
out stepNumber | The current step starting with 1, ending with numberOfSteps+1 |
out numberOfSteps | Total number of steps |
out displayText | The display text for the current step |
Response Actions | |
next | The process is not finished and continue should be called as next action |
download | The process is finished and the next call to continue will trigger the file download |
done | The process is finished |
Parameter | Description |
---|---|
out stepNumber | The current step starting with 1, ending with numberOfSteps+1 |
out numberOfSteps | Total number of steps |
out displayText | The display text for the current step |
Response Actions | |
next | The process is not finished and continue should be called as next action |
download | The process is finished and the next call to continue will trigger the file download |
done | The process is finished |
Definition at line 69 of file BatchController.php.
Public Member Functions | |
initialize (Request $request, Response $response) | |
Public Member Functions inherited from Controller | |
__construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration) | |
initialize (Request $request, Response $response) | |
execute ($method=null) | |
getRequest () | |
getResponse () | |
Public Attributes | |
const | ONE_CALL_SESSION_VARNAME = 'BatchController.oneCall' |
const | STEP_SESSION_VARNAME = 'BatchController.curStep' |
const | NUM_STEPS_VARNAME = 'BatchController.numSteps' |
const | DOWNLOAD_STEP = 'BatchController.downloadStep' |
const | WORK_PACKAGES_VARNAME = 'BatchController.workPackages' |
Protected Member Functions | |
doExecute () | |
getStepNumber () | |
addWorkPackage ($name, $size, $oids, $callback, $args=null) | |
processPart () | |
getNumberOfSteps () | |
getDisplayText ($step) | |
getDownloadFile () | |
getWorkPackage ($number) | |
Protected Member Functions inherited from Controller | |
validate () | |
executeSubAction ($action) | |
getLogger () | |
getSession () | |
getPersistenceFacade () | |
getPermissionManager () | |
getActionMapper () | |
getLocalization () | |
getMessage () | |
getConfiguration () | |
assignResponseDefaults () | |
isLocalizedRequest () | |
checkLanguageParameter () | |
Member Function Documentation
- See also
- Controller::initialize()
Definition at line 84 of file BatchController.php.
|
protected |
- See also
- Controller::doExecute()
Definition at line 137 of file BatchController.php.
|
protected |
Get the number of the current step (1..number of steps).
- Returns
- The number of the current step
Definition at line 183 of file BatchController.php.
|
protected |
Add a work package to session.
This package will be devided into sub packages of given size.
- Parameters
-
$name Display name of the package (will be supplemented by startNumber-endNumber, e.g. '1-7', '8-14', ...) $size Size of one sub package. This defines how many of the oids will be passed to the callback in one call (e.g. '7' means pass 7 oids per call) $oids An array of object ids (or other application specific package identifiers) with at least one value that will be distributed into sub packages of given size $callback The name of method to call for this package type. The callback method must accept the following parameters: - array parameter (the object ids to process in the current call)
- optionally array parameter (the additional arguments)
$args Assoziative array of additional callback arguments (application specific) (default: null)
Definition at line 200 of file BatchController.php.
|
protected |
Process the next step.
Definition at line 258 of file BatchController.php.
|
protected |
Get the number of steps to process.
- Returns
- Integer
Definition at line 278 of file BatchController.php.
|
protected |
Get the text to display for the current step.
- Parameters
-
$step The step number
Definition at line 286 of file BatchController.php.
|
protected |
Get the filename of the file to download at the end of processing.
- Returns
- String of null, if no download is created.
Definition at line 294 of file BatchController.php.
|
abstractprotected |
Get definitions of work packages.
- Parameters
-
$number The number of the work package (first number is 0, number is incremented on every call)
- Note
- This function gets called on first initialization run as often until it returns null. This allows to define different static work packages. If you would like to add work packages dynamically on subsequent runs this may be done by directly calling the BatchController::addWorkPackage() method.
- Returns
- A work packages description as assoziative array with keys 'name', 'size', 'oids', 'callback' as required for BatchController::addWorkPackage() method or null to terminate.
Member Data Documentation
const ONE_CALL_SESSION_VARNAME = 'BatchController.oneCall' |
Definition at line 72 of file BatchController.php.
const STEP_SESSION_VARNAME = 'BatchController.curStep' |
Definition at line 73 of file BatchController.php.
const NUM_STEPS_VARNAME = 'BatchController.numSteps' |
Definition at line 74 of file BatchController.php.
const DOWNLOAD_STEP = 'BatchController.downloadStep' |
Definition at line 75 of file BatchController.php.
const WORK_PACKAGES_VARNAME = 'BatchController.workPackages' |
Definition at line 76 of file BatchController.php.