PHP Класс TransitionComponent, TransitionComponent

Among form pages , auto validation and auto redirect. This will use Session.
Наследование: extends Component
Показать файл Открыть проект Примеры использования класса

Открытые свойства

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

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

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

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

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

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
Результат mixed Session data or null

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

Get all of session data.
public allData ( ) : mixed
Результат mixed Session data or null

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

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

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

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

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

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

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

Clear Session data.
public clearData ( ) : boolean
Результат boolean Success

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

Get session data from key.
public data ( string $key ) : mixed
$key string Key name
Результат mixed Session data or null

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

Alias for deleteData().
public delData ( string $key ) : boolean
$key string Key name
Результат boolean Success

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

Delete Session data from key.
public deleteData ( string $key ) : boolean
$key string Key name
Результат boolean Success

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

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

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

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)
Результат mixed Merged session data or null

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

Get Session key.
public sessionKey ( string $key, string $cname = null ) : string
$key string Key name
$cname string controller name(deprecated argument)
Результат string Session key

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

Set session data with key.
public setData ( string $key, mixed $data ) : boolean
$key string Key name
$data mixed data to set
Результат boolean Success

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

Component startup. Given automation options , It will automate.
public startup ( object &$controller ) : void
$controller object Instantiating controller
Результат void

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

Validation with model name.
public validateModel ( $model, callback $validationMethod = null ) : boolean
$validationMethod callback Method to validate
Результат boolean Success

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

$_controller публичное свойство

Holds the reference of current controller
public $_controller

$action публичное свойство

Holds the current action of the controller
public $action

$autoComplete публичное свойство

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

$autoRedirect публичное свойство

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

$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), ), ) );
public $automation

$components публичное свойство

Components to use.
public $components

$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'.
public $flashParams

$messages публичное свойство

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

$models публичное свойство

Default models.
public $models

$sessionBaseKey публичное свойство

Base of session key
public $sessionBaseKey

$validationMethod публичное свойство

Default validation method.
public $validationMethod