yii2-workflow Class Reference
  • Namespace
  • Class

Namespaces

  • raoul2000
    • workflow
      • actions
      • base
      • events
      • helpers
      • source
        • file
      • validation

Classes

  • SimpleWorkflowBehavior
  • Status
  • StatusIdConverter
  • Transition
  • Workflow
  • WorkflowBaseObject
  • WorkflowException
  • WorkflowValidationException

Interfaces

  • IStatusAccessor
  • IStatusIdConverter
  • StatusInterface
  • TransitionInterface
  • WorkflowInterface

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
Extended by raoul2000\workflow\base\StatusIdConverter implements raoul2000\workflow\base\IStatusIdConverter
Namespace: raoul2000\workflow\base
See: raoul2000\workflow\base\IStatusIdConverter
Located at base/StatusIdConverter.php

Methods summary

public
# __construct( array $config = [] )

Contruct an instance of the StatusIdConverter. The parameter map must be defined in the configuration array passed as argument. It contains the associative array used to convert statuses.

Contruct an instance of the StatusIdConverter. The parameter map must be defined in the configuration array passed as argument. It contains the associative array used to convert statuses.

Parameters

$config

Throws

yii\base\InvalidConfigException
public array
# getMap( )

Returns

array
the convertion map used by this converter
public
# setMap( array $map )

Replace the convertion map initialized in constructor by the one passed as argument.

Replace the convertion map initialized in constructor by the one passed as argument.

Parameters

$map

Throws

yii\base\InvalidCallException
public
# toSimpleWorkflow( mixed $id )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$id
$statusId

See

raoul2000\workflow\base\IStatusIdConverter::toSimpleWorkflow()

Implementation of

raoul2000\workflow\base\IStatusIdConverter::toSimpleWorkflow()
public
# toModelAttribute( mixed $id )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$id
$statusId

See

raoul2000\workflow\base\IStatusIdConverter::toModelAttribute()

Implementation of

raoul2000\workflow\base\IStatusIdConverter::toModelAttribute()

Constants summary

string VALUE_NULL
# 'null'
yii2-workflow Class Reference API documentation generated by ApiGen