Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / entityqueue / tests / modules / entityqueue_test / src / Plugin / EntityQueueHandler / Test.php
1 <?php
2
3 namespace Drupal\entityqueue_test\Plugin\EntityQueueHandler;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\entityqueue\EntityQueueHandlerBase;
7
8 /**
9  * Defines an entity queue handler for testing.
10  *
11  * @EntityQueueHandler(
12  *   id = "test",
13  *   title = @Translation("Test handler")
14  * )
15  */
16 class Test extends EntityQueueHandlerBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public function supportsMultipleSubqueues() {
22     return TRUE;
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function hasAutomatedSubqueues() {
29     return FALSE;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function defaultConfiguration() {
36     return [
37       'shape' => 'round',
38     ];
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
45     $form['shape'] = [
46       '#type' => 'textfield',
47       '#title' => 'Shape',
48       '#default_value' => $this->configuration['shape'],
49     ];
50     return $form;
51   }
52
53   /**
54    * {@inheritdoc}
55    */
56   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
57     if ($form_state->getValue('shape') === 'square') {
58       $form_state->setErrorByName('shape', $this->t('The shape can not be square.'));
59     }
60   }
61
62   /**
63    * {@inheritdoc}
64    */
65   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
66     $this->configuration['shape'] = $form_state->getValue('shape');
67   }
68
69 }