Commit 5ada0584 authored by bojanz's avatar bojanz

Rename the module to state_machine, update README.

parent 271f8256
Prototype for a Commerce 2.x workflow solution: https://www.drupal.org/node/2626988
Provides code-driven workflow functionality.
The current name is temporary, the module is not tied to Commerce in any way
and should live in its own namespace.
High level overview
-------------------
A workflow is a set of states and transitions that an entity goes through during its lifecycle.
A transition represents a one-way link between two states and has its own label.
An entity can have multiple workflows, each in its own state field.
An order might have checkout, payment, fulfilment workflows.
A node or product might have legal and marketing workflows.
The current state of a workflow is stored in a state field, which provides an API for getting and
applying transitions. An entity can have multiple workflows, each in its own state field.
An order might have checkout and payment workflows. A node might have legal and marketing workflows.
Workflow groups are used to group workflows used for the same purpose (e.g. payment workflows).
The state field provides an API for getting the allowed transitions/states, used
by validation and widgets/formatters.
Architecture
------------
[Workflow](https://github.com/bojanz/commerce_workflow/blob/8.x-1.x/src/Plugin/Workflow/WorkflowInterface.php) and [WorkflowGroup](https://github.com/bojanz/commerce_workflow/blob/8.x-1.x/src/Plugin/WorkflowGroup/WorkflowGroupInterface.php) are plugins defined in YAML, similar to menu links.
[Workflow](https://github.com/bojanz/state_machine/blob/8.x-1.x/src/Plugin/Workflow/WorkflowInterface.php) and [WorkflowGroup](https://github.com/bojanz/state_machine/blob/8.x-1.x/src/Plugin/WorkflowGroup/WorkflowGroupInterface.php) are plugins defined in YAML, similar to menu links.
This leaves room for a future entity-based UI.
Example yourmodule.workflow_groups.yml:
......@@ -59,20 +50,19 @@ default:
to: canceled
```
Transitions can be further restricted by [guards](https://github.com/bojanz/commerce_workflow/blob/8.x-1.x/src/WorkflowGuard/WorkflowGuardInterface.php), which are implemented as tagged services:
Transitions can be further restricted by [guards](https://github.com/bojanz/state_machine/blob/8.x-1.x/src/WorkflowGuard/WorkflowGuardInterface.php), which are implemented as tagged services:
```yaml
mymodule.fulfillment_guard:
class: Drupal\mymodule\WorkflowGuard\FulfillmentGuard
tags:
- { name: commerce_workflow.workflow_guard, group: order }
- { name: state_machine.workflow_guard, group: order }
```
The group argument allows the guard factory to only instantiate the guards relevant
to a specific workflow group.
The current state is stored in a [StateItem](https://github.com/bojanz/commerce_workflow/blob/8.x-1.x/src/Plugin/Field/FieldType/StateItem.php) field.
The current state is stored in a [StateItem](https://github.com/bojanz/state_machine/blob/8.x-1.x/src/Plugin/Field/FieldType/StateItem.php) field.
A field setting specifies the used workflow, or a value callback that allows
the workflow to be resolved at runtime (checkout workflow based on the used plugin, etc.
A validator is provided that ensures that the specified state is valid (exists in the
workflow and is in the allowed transitions).
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\DependencyInjection\Compiler\WorkflowGuardsPass.
* Contains \Drupal\state_machine\DependencyInjection\Compiler\WorkflowGuardsPass.
*/
namespace Drupal\commerce_workflow\DependencyInjection\Compiler;
namespace Drupal\state_machine\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
......@@ -22,7 +22,7 @@ class WorkflowGuardsPass implements CompilerPassInterface {
*/
public function process(ContainerBuilder $container) {
$guards = [];
foreach ($container->findTaggedServiceIds('commerce_workflow.workflow_guard') as $id => $attributes) {
foreach ($container->findTaggedServiceIds('state_machine.workflow_guard') as $id => $attributes) {
if (empty($attributes[0]['group'])) {
continue;
}
......@@ -30,7 +30,7 @@ class WorkflowGuardsPass implements CompilerPassInterface {
$guards[$attributes[0]['group']][] = $id;
}
$definition = $container->getDefinition('commerce_workflow.workflow_guard_factory');
$definition = $container->getDefinition('state_machine.workflow_guard_factory');
$definition->addArgument($guards);
}
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\Field\FieldType\StateItem.
* Contains \Drupal\state_machine\Plugin\Field\FieldType\StateItem.
*/
namespace Drupal\commerce_workflow\Plugin\Field\FieldType;
namespace Drupal\state_machine\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
......@@ -214,7 +214,7 @@ class StateItem extends FieldItemBase implements StateItemInterface, OptionsProv
* @param string $value
* The field value, representing the state id.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState[]
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowState[]
* The allowed states.
*/
protected function getAllowedStates($value) {
......@@ -270,7 +270,7 @@ class StateItem extends FieldItemBase implements StateItemInterface, OptionsProv
/**
* Loads the workflow used by the current field.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowInterface|false
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowInterface|false
* The workflow, or FALSE if unknown at this time.
*/
protected function loadWorkflow() {
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\Field\FieldType\StateItemInterface.
* Contains \Drupal\state_machine\Plugin\Field\FieldType\StateItemInterface.
*/
namespace Drupal\commerce_workflow\Plugin\Field\FieldType;
namespace Drupal\state_machine\Plugin\Field\FieldType;
/**
* Defines the interface for state item fields.
......@@ -15,7 +15,7 @@ interface StateItemInterface {
/**
* Gets the workflow used by the field.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowInterface|false
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowInterface|false
* The workflow, or FALSE if unknown at this time.
*/
public function getWorkflow();
......@@ -23,7 +23,7 @@ interface StateItemInterface {
/**
* Gets the allowed transitions for the current state.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition[]
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowTransition[]
* The allowed transitions.
*/
public function getTransitions();
......@@ -31,7 +31,7 @@ interface StateItemInterface {
/**
* Applies the given transition, changing the current state.
*
* @param \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition $transition
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowTransition $transition
* The transition to apply.
*/
public function applyTransition(WorkflowTransition $transition);
......@@ -46,7 +46,7 @@ interface StateItemInterface {
* changes internally, and answer via this method if the current state is
* valid.
*
* @see \Drupal\commerce_workflow\Plugin\Validation\Constraint\StateConstraintValidator
* @see \Drupal\state_machine\Plugin\Validation\Constraint\StateConstraintValidator
*
* @return bool
* TRUE if the current state is valid, FALSE otherwise.
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\Validation\Constraint\StateConstraint.
* Contains \Drupal\state_machine\Plugin\Validation\Constraint\StateConstraint.
*/
namespace Drupal\commerce_workflow\Plugin\Validation\Constraint;
namespace Drupal\state_machine\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\Validation\Constraint\StateConstraintValidator.
* Contains \Drupal\state_machine\Plugin\Validation\Constraint\StateConstraintValidator.
*/
namespace Drupal\commerce_workflow\Plugin\Validation\Constraint;
namespace Drupal\state_machine\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
......@@ -13,7 +13,7 @@ use Symfony\Component\Validator\ConstraintValidator;
/**
* Validates the State constraint.
*
* @see \Drupal\commerce_workflow\Plugin\Field\FieldType\StateItemInterface::isValid()
* @see \Drupal\state_machine\Plugin\Field\FieldType\StateItemInterface::isValid()
*/
class StateConstraintValidator extends ConstraintValidator {
......
......@@ -2,12 +2,12 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\Workflow\Workflow.
* Contains \Drupal\state_machine\Plugin\Workflow\Workflow.
*/
namespace Drupal\commerce_workflow\Plugin\Workflow;
namespace Drupal\state_machine\Plugin\Workflow;
use Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardFactoryInterface;
use Drupal\state_machine\WorkflowGuard\WorkflowGuardFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
......@@ -21,21 +21,21 @@ class Workflow extends PluginBase implements WorkflowInterface, ContainerFactory
/**
* The workflow guard factory.
*
* @var \Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardFactoryInterface
* @var \Drupal\state_machine\WorkflowGuard\WorkflowGuardFactoryInterface
*/
protected $guardFactory;
/**
* The initialized states.
*
* @var \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState[]
* @var \Drupal\state_machine\Plugin\Workflow\WorkflowState[]
*/
protected $states = [];
/**
* The initialized transitions.
*
* @var \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition[]
* @var \Drupal\state_machine\Plugin\Workflow\WorkflowTransition[]
*/
protected $transitions = [];
......@@ -48,7 +48,7 @@ class Workflow extends PluginBase implements WorkflowInterface, ContainerFactory
* The workflow plugin_id.
* @param mixed $plugin_definition
* The workflow plugin implementation definition.
* @param \Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardFactoryInterface $guard_factory
* @param \Drupal\state_machine\WorkflowGuard\WorkflowGuardFactoryInterface $guard_factory
* The workflow guard factory.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, WorkflowGuardFactoryInterface $guard_factory) {
......@@ -78,7 +78,7 @@ class Workflow extends PluginBase implements WorkflowInterface, ContainerFactory
$configuration,
$plugin_id,
$plugin_definition,
$container->get('commerce_workflow.workflow_guard_factory')
$container->get('state_machine.workflow_guard_factory')
);
}
......@@ -158,7 +158,7 @@ class Workflow extends PluginBase implements WorkflowInterface, ContainerFactory
/**
* Gets whether the given transition is allowed.
*
* @param \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition $transition
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowTransition $transition
* The transition.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The parent entity.
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\WorkflowGroup\WorkflowInterface.
* Contains \Drupal\state_machine\Plugin\WorkflowGroup\WorkflowInterface.
*/
namespace Drupal\commerce_workflow\Plugin\Workflow;
namespace Drupal\state_machine\Plugin\Workflow;
use Drupal\Core\Entity\EntityInterface;
......@@ -33,7 +33,7 @@ interface WorkflowInterface {
/**
* Gets the workflow states.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState[]
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowState[]
* The states.
*/
public function getStates();
......@@ -44,7 +44,7 @@ interface WorkflowInterface {
* @param string $id
* The state id.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState|null
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowState|null
* The requested state, or NULL if not found.
*/
public function getState($id);
......@@ -52,7 +52,7 @@ interface WorkflowInterface {
/**
* Gets the workflow transitions.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition[]
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowTransition[]
* The transitions.
*/
public function getTransitions();
......@@ -63,7 +63,7 @@ interface WorkflowInterface {
* @param string $id
* The transition id.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition|null
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowTransition|null
* The requested transition, or NULL if not found.
*/
public function getTransition($id);
......@@ -77,7 +77,7 @@ interface WorkflowInterface {
* @param string $state_id
* The state id.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition[]
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowTransition[]
* The possible transitions.
*/
public function getPossibleTransitions($state_id);
......@@ -90,7 +90,7 @@ interface WorkflowInterface {
* @param \Drupal\Core\Entity\EntityInterface $entity
* The parent entity.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition[]
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowTransition[]
* The allowed transitions.
*/
public function getAllowedTransitions($state_id, EntityInterface $entity);
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState.
* Contains \Drupal\state_machine\Plugin\Workflow\WorkflowState.
*/
namespace Drupal\commerce_workflow\Plugin\Workflow;
namespace Drupal\state_machine\Plugin\Workflow;
/**
* Defines the class for workflow states.
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition.
* Contains \Drupal\state_machine\Plugin\Workflow\WorkflowTransition.
*/
namespace Drupal\commerce_workflow\Plugin\Workflow;
namespace Drupal\state_machine\Plugin\Workflow;
/**
* Defines the class for workflow transitions.
......@@ -29,14 +29,14 @@ class WorkflowTransition {
/**
* The "from" states.
*
* @var \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState[]
* @var \Drupal\state_machine\Plugin\Workflow\WorkflowState[]
*/
protected $fromStates;
/**
* The "to" state.
*
* @var \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState
* @var \Drupal\state_machine\Plugin\Workflow\WorkflowState
*/
protected $toState;
......@@ -47,9 +47,9 @@ class WorkflowTransition {
* The transition id.
* @param string $label
* The transition label.
* @param \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState[] $from_states
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowState[] $from_states
* The "from" states.
* @param \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState $to_state
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowState $to_state
* The "to" state.
*/
public function __construct($id, $label, array $from_states, WorkflowState $to_state) {
......@@ -82,7 +82,7 @@ class WorkflowTransition {
/**
* Gets the "from" states.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState[]
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowState[]
* The "from" states.
*/
public function getFromStates() {
......@@ -92,7 +92,7 @@ class WorkflowTransition {
/**
* Gets the "to" state.
*
* @return \Drupal\commerce_workflow\Plugin\Workflow\WorkflowState
* @return \Drupal\state_machine\Plugin\Workflow\WorkflowState
* The "to" state.
*/
public function getToState() {
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\WorkflowGroup\WorkflowGroup.
* Contains \Drupal\state_machine\Plugin\WorkflowGroup\WorkflowGroup.
*/
namespace Drupal\commerce_workflow\Plugin\WorkflowGroup;
namespace Drupal\state_machine\Plugin\WorkflowGroup;
use Drupal\Core\Plugin\PluginBase;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\Plugin\WorkflowGroup\WorkflowGroupInterface.
* Contains \Drupal\state_machine\Plugin\WorkflowGroup\WorkflowGroupInterface.
*/
namespace Drupal\commerce_workflow\Plugin\WorkflowGroup;
namespace Drupal\state_machine\Plugin\WorkflowGroup;
/**
* Defines the interface for workflow groups.
......
......@@ -2,19 +2,19 @@
/**
* @file
* Contains \Drupal\commerce_workflow\CommerceWorkflowServiceProvider.
* Contains \Drupal\state_machine\StateMachineServiceProvider.
*/
namespace Drupal\commerce_workflow;
namespace Drupal\state_machine;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\commerce_workflow\DependencyInjection\Compiler\WorkflowGuardsPass;
use Drupal\state_machine\DependencyInjection\Compiler\WorkflowGuardsPass;
/**
* Registers the workflow guard compiler pass.
*/
class CommerceWorkflowServiceProvider implements ServiceProviderInterface {
class StateMachineServiceProvider implements ServiceProviderInterface {
/**
* {@inheritdoc}
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\WorkflowGroupManager.
* Contains \Drupal\state_machine\WorkflowGroupManager.
*/
namespace Drupal\commerce_workflow;
namespace Drupal\state_machine;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Cache\CacheBackendInterface;
......@@ -17,7 +17,7 @@ use Drupal\Core\Plugin\Discovery\YamlDiscovery;
/**
* Manages discovery and instantiation of workflow_group plugins.
*
* @see \Drupal\commerce_workflow\Plugin\WorkflowGroup\WorkflowGroupInterface
* @see \Drupal\state_machine\Plugin\WorkflowGroup\WorkflowGroupInterface
* @see plugin_api
*/
class WorkflowGroupManager extends DefaultPluginManager implements WorkflowGroupManagerInterface {
......@@ -31,9 +31,9 @@ class WorkflowGroupManager extends DefaultPluginManager implements WorkflowGroup
'id' => '',
'label' => '',
'entity_type' => '',
'class' => 'Drupal\commerce_workflow\Plugin\WorkflowGroup\WorkflowGroup',
'class' => 'Drupal\state_machine\Plugin\WorkflowGroup\WorkflowGroup',
// Groups can override the default workflow class for advanced use cases.
'workflow_class' => '\Drupal\commerce_workflow\Plugin\Workflow\Workflow',
'workflow_class' => '\Drupal\state_machine\Plugin\Workflow\Workflow',
];
/**
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\WorkflowGroupManagerInterface.
* Contains \Drupal\state_machine\WorkflowGroupManagerInterface.
*/
namespace Drupal\commerce_workflow;
namespace Drupal\state_machine;
use Drupal\Component\Plugin\PluginManagerInterface;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardFactory.
* Contains \Drupal\state_machine\WorkflowGuard\WorkflowGuardFactory.
*/
namespace Drupal\commerce_workflow\WorkflowGuard;
namespace Drupal\state_machine\WorkflowGuard;
use Symfony\Component\DependencyInjection\ContainerInterface;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardFactoryInterface.
* Contains \Drupal\state_machine\WorkflowGuard\WorkflowGuardFactoryInterface.
*/
namespace Drupal\commerce_workflow\WorkflowGuard;
namespace Drupal\state_machine\WorkflowGuard;
/**
* Defines the interface for workflow guard factories.
......@@ -18,7 +18,7 @@ interface WorkflowGuardFactoryInterface {
* @param string $group_id
* The group id.
*
* @return \Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardInterface[]
* @return \Drupal\state_machine\WorkflowGuard\WorkflowGuardInterface[]
*/
public function get($group_id);
......
......@@ -2,13 +2,13 @@
/**
* @file
* Contains \Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardInterface.
* Contains \Drupal\state_machine\WorkflowGuard\WorkflowGuardInterface.
*/
namespace Drupal\commerce_workflow\WorkflowGuard;
namespace Drupal\state_machine\WorkflowGuard;
use Drupal\commerce_workflow\Plugin\Workflow\WorkflowInterface;
use Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition;
use Drupal\state_machine\Plugin\Workflow\WorkflowInterface;
use Drupal\state_machine\Plugin\Workflow\WorkflowTransition;
use Drupal\Core\Entity\EntityInterface;
/**
......@@ -25,9 +25,9 @@ interface WorkflowGuardInterface {
/**
* Checks whether the given transition is allowed.
*
* @param \Drupal\commerce_workflow\Plugin\Workflow\WorkflowTransition $transition
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowTransition $transition
* The transition.
* @param \Drupal\commerce_workflow\Plugin\Workflow\WorkflowInterface $workflow
* @param \Drupal\state_machine\Plugin\Workflow\WorkflowInterface $workflow
* The workflow.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The parent entity.
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\WorkflowManager.
* Contains \Drupal\state_machine\WorkflowManager.
*/
namespace Drupal\commerce_workflow;
namespace Drupal\state_machine;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Cache\CacheBackendInterface;
......@@ -17,7 +17,7 @@ use Drupal\Core\Plugin\Discovery\YamlDiscovery;
/**
* Manages discovery and instantiation of workflow plugins.
*
* @see \Drupal\commerce_workflow\Plugin\Workflow\WorkflowInterface
* @see \Drupal\state_machine\Plugin\Workflow\WorkflowInterface
* @see plugin_api
*/
class WorkflowManager extends DefaultPluginManager implements WorkflowManagerInterface {
......@@ -25,7 +25,7 @@ class WorkflowManager extends DefaultPluginManager implements WorkflowManagerInt
/**
* The workflow group manager.
*
* @var \Drupal\commerce_workflow\WorkflowGroupManagerInterface
* @var \Drupal\state_machine\WorkflowGroupManagerInterface
*/
protected $groupManager;
......@@ -49,7 +49,7 @@ class WorkflowManager extends DefaultPluginManager implements WorkflowManagerInt
* The module handler.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* The cache backend.
* @param \Drupal\commerce_workflow\WorkflowGroupManagerInterface $group_manager
* @param \Drupal\state_machine\WorkflowGroupManagerInterface $group_manager
* The workflow group manager.
*/
public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, WorkflowGroupManagerInterface $group_manager) {
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_workflow\WorkflowManagerInterface.
* Contains \Drupal\state_machine\WorkflowManagerInterface.
*/
namespace Drupal\commerce_workflow;
namespace Drupal\state_machine;
use Drupal\Component\Plugin\PluginManagerInterface;
......
name: Commerce Workflow
name: State Machine
type: module
description: Provides workflow functionality.
description: Provides code-driven workflow functionality.
core: 8.x
package: Other
......@@ -8,13 +8,13 @@
/**
* Implements hook_field_widget_info_alter().
*/
function commerce_workflow_field_widget_info_alter(array &$info) {
function state_machine_field_widget_info_alter(array &$info) {
$info['options_select']['field_types'][] = 'state';
}
/**
* Implements hook_field_formatter_info_alter().
*/
function commerce_workflow_field_formatter_info_alter(array &$info) {
function state_machine_field_formatter_info_alter(array &$info) {
$info['list_default']['field_types'][] = 'state';
}
services:
commerce_workflow.workflow_guard_factory:
class: Drupal\commerce_workflow\WorkflowGuard\WorkflowGuardFactory
state_machine.workflow_guard_factory:
class: Drupal\state_machine\WorkflowGuard\WorkflowGuardFactory
arguments: ['@service_container']
plugin.manager.workflow:
class: Drupal\commerce_workflow\WorkflowManager
class: Drupal\state_machine\WorkflowManager
arguments: ['@module_handler', '@cache.discovery', '@plugin.manager.workflow_group']
plugin.manager.workflow_group:
class: Drupal\commerce_workflow\WorkflowGroupManager
class: Drupal\state_machine\WorkflowGroupManager
arguments: ['@module_handler', '@cache.discovery']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment