PaymentWorkflow extends Workflow
FinalYes
Base class for simple business processes (workflows).
Usage:
$workflow = new PublishArticleWorkflow;
$workflow->getStage(); // ArticleStage::DRAFT
if ($workflow->canSwitchToStage(ArticleStage::PUBLISHED)) {
$workflow->setStage(ArticleStage::PUBLISHED);
}
$workflow->atStage(ArticleStage::PUBLISHED); // true
Table of Contents
Methods
- __construct() : mixed
- atStage() : bool
- Check if workflow in $currentStage
- canSwitchToStage() : bool
- Check if transition from current stage to next stage allowed.
- createFrom() : PaymentWorkflow
- getEntityId() : int
- Returns current entity identifier
- getInitialStage() : string
- Returns initial entity stage
- getStage() : string
- Fetches current stage from database
- getStages() : array<string|int, string>
- Returns list of all available stages
- getWorkflowCode() : string
- Returns unique workflow code
- resetStage() : bool
- Removes stage record for current entity, so entity forces initialing state
- setStage() : bool
- Tries to apply next stage
Methods
__construct()
public
__construct(Payment $payment) : mixed
Parameters
- $payment : Payment
atStage()
Check if workflow in $currentStage
public
atStage(string $currentStage) : bool
Parameters
- $currentStage : string
Return values
boolcanSwitchToStage()
Check if transition from current stage to next stage allowed.
public
canSwitchToStage(string $nextStage) : bool
Parameters
- $nextStage : string
Tags
Return values
boolcreateFrom()
public
static createFrom(Payment $payment) : PaymentWorkflow
Parameters
- $payment : Payment
Return values
PaymentWorkflowgetEntityId()
Returns current entity identifier
public
getEntityId() : int
Tags
Return values
intgetInitialStage()
Returns initial entity stage
public
getInitialStage() : string
Tags
Return values
stringgetStage()
Fetches current stage from database
public
getStage() : string
Return values
stringgetStages()
Returns list of all available stages
public
static getStages() : array<string|int, string>
Tags
Return values
array<string|int, string>getWorkflowCode()
Returns unique workflow code
public
static getWorkflowCode() : string
Tags
Return values
stringresetStage()
Removes stage record for current entity, so entity forces initialing state
public
resetStage() : bool
Return values
bool —true if record removed or already not exists, false otherwise
setStage()
Tries to apply next stage
public
setStage(string $nextStage) : bool
Parameters
- $nextStage : string
Return values
bool —true if transition allowed and stage saved, false otherwise