Bitrix API

Workflow

AbstractYes

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

atStage()  : bool
Check if workflow in $currentStage
canSwitchToStage()  : bool
Check if transition from current stage to next stage allowed.
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

atStage()

Check if workflow in $currentStage

public atStage(string $currentStage) : bool
Parameters
$currentStage : string
Return values
bool

canSwitchToStage()

Check if transition from current stage to next stage allowed.

public canSwitchToStage(string $nextStage) : bool

By default, all transitions allowed, override it if needed.

Parameters
$nextStage : string
Return values
bool

getEntityId()

Returns current entity identifier

public abstract getEntityId() : int
Return values
int

getInitialStage()

Returns initial entity stage

public abstract getInitialStage() : string
Return values
string

getStage()

Fetches current stage from database

public getStage() : string
Return values
string

getStages()

Returns list of all available stages

public abstract static getStages() : array<string|int, string>
Return values
array<string|int, string>

getWorkflowCode()

Returns unique workflow code

public abstract static getWorkflowCode() : string
Return values
string

resetStage()

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


        
On this page

Search results