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.

Conceptually the process is divided into sub actions (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:

Action default
Initialize the work packages and process the first action.

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
out status The value of the response action
Response Actions
progress 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
Action continue
Continue to process the next action.

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 next step (since the first request)
out status The value of the response action
Response Actions
progress 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
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 72 of file BatchController.php.

+ Inheritance diagram for BatchController:

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 REQUEST_VAR = 'request'
 
const ONE_CALL_VAR = 'oneCall'
 
const STEP_VAR = 'step'
 
const NUM_STEPS_VAR = 'numSteps'
 
const DOWNLOAD_STEP_VAR = 'downloadStep'
 
const PACKAGES_VAR = 'packages'
 
- Public Attributes inherited from Controller
const CSRF_TOKEN_PARAM = 'csrf_token'
 

Protected Member Functions

 doExecute ($method=null)
 
 getStepNumber ()
 
 addWorkPackage ($name, $size, $oids, $callback, $args=null)
 
 processPart ($step)
 
 getRequestValue ($name)
 
 getNumberOfSteps ()
 
 getDisplayText ($step)
 
 getDownloadFile ()
 
 getWorkPackage ($number)
 
 cleanup ()
 
- Protected Member Functions inherited from Controller
 validate ()
 
 doExecute ($method=null)
 
 executeSubAction ($action)
 
 redirect ($location, $key=null, $data=null)
 
 getLogger ()
 
 getSession ()
 
 getPersistenceFacade ()
 
 getPermissionManager ()
 
 getActionMapper ()
 
 getLocalization ()
 
 getMessage ()
 
 getConfiguration ()
 
 requireTransaction ()
 
 endTransaction ($commit)
 
 isLocalizedRequest ()
 
 checkLanguageParameter ()
 
 generateCsrfToken ($name)
 
 validateCsrfToken ($name)
 
 getLocalSessionValue ($key, $default=null)
 
 setLocalSessionValue ($key, $value)
 
 clearLocalSessionValues ()
 

Member Function Documentation

initialize ( Request  $request,
Response  $response 
)
See also
Controller::initialize()

Definition at line 88 of file BatchController.php.

doExecute (   $method = null)
protected
See also
Controller::doExecute()

Definition at line 138 of file BatchController.php.

getStepNumber ( )
protected

Get the number of the current step (1..number of steps).

Returns
The number of the current step

Definition at line 194 of file BatchController.php.

addWorkPackage (   $name,
  $size,
  $oids,
  $callback,
  $args = null 
)
protected

Add a work package to session.

This package will be divided into sub packages of given size.

Parameters
$nameDisplay name of the package (will be supplemented by startNumber-endNumber, e.g. '1-7', '8-14', ...)
$sizeSize 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)
$oidsAn array of object ids (or other application specific package identifiers) that will be distributed into sub packages of given size
$callbackThe name of method to call for this package type. The callback method must accept the following parameters:
  1. array parameter (the object ids to process in the current call)
  2. optionally array parameter (the additional arguments)
$argsAssociative array of additional callback arguments (application specific) (default: null)

Definition at line 209 of file BatchController.php.

processPart (   $step)
protected

Process the given step (1-base).

Parameters
$stepThe step to process

Definition at line 259 of file BatchController.php.

getRequestValue (   $name)
protected

Get a value from the initial request.

Parameters
$nameThe name of the value
Returns
Mixed

Definition at line 284 of file BatchController.php.

getNumberOfSteps ( )
protected

Get the number of steps to process.

Returns
Integer

Definition at line 293 of file BatchController.php.

getDisplayText (   $step)
protected

Get the text to display for the current step.

Parameters
$stepThe step number

Definition at line 301 of file BatchController.php.

getDownloadFile ( )
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 311 of file BatchController.php.

getWorkPackage (   $number)
abstractprotected

Get definitions of work packages.

Parameters
$numberThe 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 associative array with keys 'name', 'size', 'oids', 'callback' as required for BatchController::addWorkPackage() method or null to terminate.
cleanup ( )
protected

Clean up after all tasks are finished.

Note
Subclasses may override this to do custom clean up, but should call the parent method.

Definition at line 330 of file BatchController.php.

Member Data Documentation

const REQUEST_VAR = 'request'

Definition at line 75 of file BatchController.php.

const ONE_CALL_VAR = 'oneCall'

Definition at line 76 of file BatchController.php.

const STEP_VAR = 'step'

Definition at line 77 of file BatchController.php.

const NUM_STEPS_VAR = 'numSteps'

Definition at line 78 of file BatchController.php.

const DOWNLOAD_STEP_VAR = 'downloadStep'

Definition at line 79 of file BatchController.php.

const PACKAGES_VAR = 'packages'

Definition at line 80 of file BatchController.php.