274ddd6314f18096e9836723acdc8ae25e65ec2e
[yaffs-website] / web / core / modules / workflows / src / Plugin / WorkflowTypeStateFormBase.php
1 <?php
2
3 namespace Drupal\workflows\Plugin;
4
5 use Drupal\Component\Plugin\PluginAwareInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface;
7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\Plugin\PluginFormInterface;
9 use Drupal\Core\StringTranslation\StringTranslationTrait;
10
11 /**
12  * A base class for workflow type state forms.
13  */
14 abstract class WorkflowTypeStateFormBase implements PluginFormInterface, PluginAwareInterface {
15
16   use StringTranslationTrait;
17
18   /**
19    * The workflow type.
20    *
21    * @var \Drupal\workflows\WorkflowTypeInterface
22    */
23   protected $workflowType;
24
25   /**
26    * {@inheritdoc}
27    */
28   public function setPlugin(PluginInspectionInterface $plugin) {
29     $this->workflowType = $plugin;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
42     $values = $form_state->getValues();
43     $state = $form_state->get('state');
44     $configuration = $this->workflowType->getConfiguration();
45     $configuration['states'][$state->id()] = $values + $configuration['states'][$state->id()];
46     $this->workflowType->setConfiguration($configuration);
47   }
48
49 }