Class StatusIdConverter
This class implements a status Id converter.
The conversion is based on an array where key are valid status ID from the simpleWorkflow behavior point of view, and values are status ID suitable to be stored in the owner model.
A typical usage for this converter is when the definition of the status column in the underlying table is not able to store a string value and when modifying column type is not an option. If for instance the status column type is integer, then the following example conversion table could be used :
$map = [ 'post/new' => 12, 'post/corrected' => 25, 'post/published' => 1, 'post/archived' => 6, StatusIdConverter::VALUE_NULL => 'some value', 'workflow/Status' => StatusIdConverter::VALUE_NULL ]
Note that if the NULL value must be part of the conversion, you should use the VALUE_NULL
constant instead of the actual 'null' value.
For example in the conversion table below, the fact for the owner model to be outside a workflow,
would mean that the actual status column would be set to 25. In the same way, any model with a
status column equals to NULL, is considered as being in status 'post/toDelete' :
$map = [ StatusIdConverter::VALUE_NULL => 25, 'post/toDelete' => StatusIdConverter::VALUE_NULL ];
- yii\base\Object
- raoul2000\workflow\base\StatusIdConverter implements raoul2000\workflow\base\IStatusIdConverter
See:
raoul2000\workflow\base\IStatusIdConverter
Located at base/StatusIdConverter.php
Methods summary
public
|
#
__construct( array $config = [] )
Contruct an instance of the StatusIdConverter.
The parameter |
public
array
|
|
public
|
#
setMap( array $map )
Replace the convertion map initialized in constructor by the one passed as argument. |
public
|
|
public
|
Constants summary
string |
VALUE_NULL
|
#
'null'
|