public function Workflow::__construct in State Machine 8
Constructs a new Workflow object.
Parameters
array $configuration: The plugin configuration.
string $plugin_id: The workflow plugin_id.
mixed $plugin_definition: The workflow plugin implementation definition.
\Drupal\state_machine\Guard\GuardFactoryInterface $guard_factory: The guard factory.
Overrides PluginBase::__construct
File
- src/
Plugin/ Workflow/ Workflow.php, line 49
Class
- Workflow
- Defines the class for workflows.
Namespace
Drupal\state_machine\Plugin\WorkflowCode
public function __construct(array $configuration, $plugin_id, $plugin_definition, GuardFactoryInterface $guard_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->guardFactory = $guard_factory;
// Populate value objects for states and transitions.
foreach ($plugin_definition['states'] as $id => $state_definition) {
$this->states[$id] = new WorkflowState($id, $state_definition['label']);
}
foreach ($plugin_definition['transitions'] as $id => $transition_definition) {
$label = $transition_definition['label'];
$from_states = [];
foreach ($transition_definition['from'] as $from_state) {
$from_states[$from_state] = $this->states[$from_state];
}
$to_state = $this->states[$transition_definition['to']];
$this->transitions[$id] = new WorkflowTransition($id, $label, $from_states, $to_state);
}
}