3 namespace Drupal\workflow_type_test\Plugin\WorkflowType;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\StringTranslation\StringTranslationTrait;
7 use Drupal\workflows\Plugin\WorkflowTypeBase;
8 use Drupal\workflows\StateInterface;
9 use Drupal\workflows\TransitionInterface;
10 use Drupal\workflows\WorkflowInterface;
11 use Drupal\workflow_type_test\DecoratedState;
12 use Drupal\workflow_type_test\DecoratedTransition;
18 * id = "workflow_type_complex_test",
19 * label = @Translation("Workflow Type Complex Test"),
22 class ComplexTestType extends WorkflowTypeBase {
24 use StringTranslationTrait;
29 public function decorateState(StateInterface $state) {
30 if (isset($this->configuration['states'][$state->id()])) {
31 $state = new DecoratedState($state, $this->configuration['states'][$state->id()]['extra']);
34 $state = new DecoratedState($state);
42 public function decorateTransition(TransitionInterface $transition) {
43 if (isset($this->configuration['transitions'][$transition->id()])) {
44 $transition = new DecoratedTransition($transition, $this->configuration['transitions'][$transition->id()]['extra']);
47 $transition = new DecoratedTransition($transition);
55 public function buildStateConfigurationForm(FormStateInterface $form_state, WorkflowInterface $workflow, StateInterface $state = NULL) {
56 /** @var \Drupal\workflow_type_test\DecoratedState $state */
59 '#type' => 'textfield',
60 '#title' => $this->t('Extra'),
61 '#description' => $this->t('Extra information added to state'),
62 '#default_value' => isset($state) ? $state->getExtra() : FALSE,
70 public function buildTransitionConfigurationForm(FormStateInterface $form_state, WorkflowInterface $workflow, TransitionInterface $transition = NULL) {
71 /** @var \Drupal\workflow_type_test\DecoratedTransition $transition */
74 '#type' => 'textfield',
75 '#title' => $this->t('Extra'),
76 '#description' => $this->t('Extra information added to transition'),
77 '#default_value' => isset($transition) ? $transition->getExtra() : FALSE,
85 public function onDependencyRemoval(array $dependencies) {
86 // Always return TRUE to allow the logic in
87 // \Drupal\workflows\Entity\Workflow::onDependencyRemoval() to be tested.