WorkflowTypeStateFormBase.php

Same filename and directory in other branches
  1. 8.9.x core/modules/workflows/src/Plugin/WorkflowTypeStateFormBase.php
  2. 10 core/modules/workflows/src/Plugin/WorkflowTypeStateFormBase.php
  3. 11.x core/modules/workflows/src/Plugin/WorkflowTypeStateFormBase.php

Namespace

Drupal\workflows\Plugin

File

core/modules/workflows/src/Plugin/WorkflowTypeStateFormBase.php

View source
<?php

namespace Drupal\workflows\Plugin;

use Drupal\Component\Plugin\PluginAwareInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * A base class for workflow type state forms.
 */
abstract class WorkflowTypeStateFormBase implements PluginFormInterface, PluginAwareInterface {
    use StringTranslationTrait;
    
    /**
     * The workflow type.
     *
     * @var \Drupal\workflows\WorkflowTypeInterface
     */
    protected $workflowType;
    
    /**
     * {@inheritdoc}
     */
    public function setPlugin(PluginInspectionInterface $plugin) {
        $this->workflowType = $plugin;
    }
    
    /**
     * {@inheritdoc}
     */
    public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
        $values = $form_state->getValues();
        $state = $form_state->get('state');
        $configuration = $this->workflowType
            ->getConfiguration();
        $configuration['states'][$state->id()] = $values + $configuration['states'][$state->id()];
        $this->workflowType
            ->setConfiguration($configuration);
    }

}

Classes

Title Deprecated Summary
WorkflowTypeStateFormBase A base class for workflow type state forms.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.