PHP Class TransitionComponent, TransitionComponent

Among form pages , auto validation and auto redirect. This will use Session.
Inheritance: extends Component
Mostrar archivo Open project: hiromi2424/TransitionComponent Class Usage Examples

Public Properties

Property Type Description
$_controller Holds the reference of current controller
$action Holds the current action of the controller
$autoComplete Turns on or off auto loading session data to Controller::data.
$autoRedirect Turns on or off auto redirect when data passes validation or session data of previous action is empty.
$automation When Array given, This automate within these key as actions. Example. beforeFilter in controller $this->Transition->automation = array( 'action' => array( 'nextStep' => 'nextAction', 'models' => array('Model1', 'Model2'), 'prev' => 'prevAction', 'validationMethod' => array(&$this->Model3, 'behaviorMethod'), 'messages' => array( 'invalid' => __('your input was wrong.', true), 'prev' => __('wrong transition.', true), ), ) );
$components Components to use.
$flashParams "element" key Element to wrap flash message in. "params" key , Parameters to be sent to layout as view variables. "key" key , Message key, default is 'flash'.
$messages "invalid" key , When it cannot pass validation. "prev" key , When session has no data for previous action.
$models Default models.
$sessionBaseKey Base of session key
$validationMethod Default validation method.

Public Methods

Method Description
_autoLoadModels ( mixed $models ) : mixed Loading Default/UserSetting Model names.
allData ( ) : mixed Get all of session data.
automate ( mixed $nextStep, mixed $models = null, mixed $prev = null, callback $validationMethod = null, array $messages = [] ) : boolean Automation method.
checkData ( mixed $nextStep = null, mixed $models = null, callback $validationMethod = null, $message = null, string $sessionKey = null ) : boolean Checking data of current controller with auto validation , auto redirection , auto setFlash() , and auto restoring data
checkPrev ( mixed $prev, string $message = null, string $prevAction = null ) : boolean Check previous session data.
clearData ( ) : boolean Clear Session data.
data ( string $key ) : mixed Get session data from key.
delData ( string $key ) : boolean Alias for deleteData().
deleteData ( string $key ) : boolean Delete Session data from key.
initialize ( object &$controller, array $settings = [] ) : void Initialize the TransitionComponent
mergedData ( string $callback = 'Set::merge' ) : mixed Get merged session data.
sessionKey ( string $key, string $cname = null ) : string Get Session key.
setData ( string $key, mixed $data ) : boolean Set session data with key.
startup ( object &$controller ) : void Component startup. Given automation options , It will automate.
validateModel ( $model, callback $validationMethod = null ) : boolean Validation with model name.

Method Details

_autoLoadModels() public method

Given $models as null, try to load model name from Controller::modelClass
public _autoLoadModels ( mixed $models ) : mixed
$models mixed a name or array of names
return mixed Session data or null

allData() public method

Get all of session data.
public allData ( ) : mixed
return mixed Session data or null

automate() public method

Automation method.
public automate ( mixed $nextStep, mixed $models = null, mixed $prev = null, callback $validationMethod = null, array $messages = [] ) : boolean
$nextStep mixed Next step url (will be given Controller::redirect())
$models mixed Models for validation
$prev mixed Previous action for check
$validationMethod callback Method to validate
$messages array Messages to Controller::setFlash()
return boolean Success

checkData() public method

Checking data of current controller with auto validation , auto redirection , auto setFlash() , and auto restoring data
public checkData ( mixed $nextStep = null, mixed $models = null, callback $validationMethod = null, $message = null, string $sessionKey = null ) : boolean
$nextStep mixed Next step url (will be passed to Controller::redirect())
$models mixed Models for validation
$validationMethod callback Method to validate
$sessionKey string Session key to store
return boolean Success

checkPrev() public method

Check previous session data.
public checkPrev ( mixed $prev, string $message = null, string $prevAction = null ) : boolean
$prev mixed Previous action for check
$message string A Message to Controller::setFlash()
$prevAction string Previous action to Redirect.
return boolean Success

clearData() public method

Clear Session data.
public clearData ( ) : boolean
return boolean Success

data() public method

Get session data from key.
public data ( string $key ) : mixed
$key string Key name
return mixed Session data or null

delData() public method

Alias for deleteData().
public delData ( string $key ) : boolean
$key string Key name
return boolean Success

deleteData() public method

Delete Session data from key.
public deleteData ( string $key ) : boolean
$key string Key name
return boolean Success

initialize() public method

Initialize the TransitionComponent
public initialize ( object &$controller, array $settings = [] ) : void
$controller object Controller instance for the request
$settings array Settings to set to the component
return void

mergedData() public method

Get merged session data.
public mergedData ( string $callback = 'Set::merge' ) : mixed
$callback string Callback method to merging. valid callback type or Sring like "Set::merge" can be accepted.(optional)
return mixed Merged session data or null

sessionKey() public method

Get Session key.
public sessionKey ( string $key, string $cname = null ) : string
$key string Key name
$cname string controller name(deprecated argument)
return string Session key

setData() public method

Set session data with key.
public setData ( string $key, mixed $data ) : boolean
$key string Key name
$data mixed data to set
return boolean Success

startup() public method

Component startup. Given automation options , It will automate.
public startup ( object &$controller ) : void
$controller object Instantiating controller
return void

validateModel() public method

Validation with model name.
public validateModel ( $model, callback $validationMethod = null ) : boolean
$validationMethod callback Method to validate
return boolean Success

Property Details

$_controller public_oe property

Holds the reference of current controller
public $_controller

$action public_oe property

Holds the current action of the controller
public $action

$autoComplete public_oe property

Turns on or off auto loading session data to Controller::data.
public $autoComplete

$autoRedirect public_oe property

Turns on or off auto redirect when data passes validation or session data of previous action is empty.
public $autoRedirect

$automation public_oe property

When Array given, This automate within these key as actions. Example. beforeFilter in controller $this->Transition->automation = array( 'action' => array( 'nextStep' => 'nextAction', 'models' => array('Model1', 'Model2'), 'prev' => 'prevAction', 'validationMethod' => array(&$this->Model3, 'behaviorMethod'), 'messages' => array( 'invalid' => __('your input was wrong.', true), 'prev' => __('wrong transition.', true), ), ) );
public $automation

$components public_oe property

Components to use.
public $components

$flashParams public_oe property

"element" key Element to wrap flash message in. "params" key , Parameters to be sent to layout as view variables. "key" key , Message key, default is 'flash'.
public $flashParams

$messages public_oe property

"invalid" key , When it cannot pass validation. "prev" key , When session has no data for previous action.
public $messages

$models public_oe property

Default models.
public $models

$sessionBaseKey public_oe property

Base of session key
public $sessionBaseKey

$validationMethod public_oe property

Default validation method.
public $validationMethod