Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / entityqueue / src / EntityQueueHandlerBase.php
1 <?php
2
3 namespace Drupal\entityqueue;
4
5 use Drupal\Component\Plugin\PluginBase;
6 use Drupal\Component\Utility\NestedArray;
7 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
8 use Drupal\Core\Entity\EntityStorageInterface;
9 use Drupal\Core\Form\FormStateInterface;
10 use Drupal\Core\StringTranslation\StringTranslationTrait;
11
12 /**
13  * Base class for EntityQueueHandler plugins.
14  */
15 abstract class EntityQueueHandlerBase extends PluginBase implements EntityQueueHandlerInterface {
16
17   use DependencySerializationTrait;
18   use StringTranslationTrait;
19
20   /**
21    * The entity queue that is using this plugin.
22    *
23    * @var \Drupal\entityqueue\Entity\EntityQueue
24    */
25   protected $queue;
26
27   /**
28    * {@inheritdoc}
29    */
30   public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
31     parent::__construct($configuration, $plugin_id, $plugin_definition);
32     $this->setConfiguration($configuration);
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function getConfiguration() {
39     return $this->configuration;
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function setConfiguration(array $configuration) {
46     $this->configuration = NestedArray::mergeDeep($this->defaultConfiguration(), $configuration);
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function defaultConfiguration() {
53     return [];
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function calculateDependencies() {
60     return [];
61   }
62
63   /**
64    * {@inheritdoc}
65    */
66   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
67     return $form;
68   }
69
70   /**
71    * {@inheritdoc}
72    */
73   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
74     // Override this.
75   }
76
77   /**
78    * {@inheritdoc}
79    */
80   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
81     // Override this.
82   }
83
84   /**
85    * {@inheritdoc}
86    */
87   public function setQueue(EntityQueueInterface $queue) {
88     $this->queue = $queue;
89
90     return $this;
91   }
92
93   /**
94    * {@inheritdoc}
95    */
96   public function getQueueListBuilderOperations() {
97     // Add an operation to list all subqueues by default.
98     $operations['view_subqueues'] = [
99       'title' => $this->t('View subqueues'),
100       'weight' => -9,
101       'url' => $this->queue->urlInfo('subqueue-list'),
102     ];
103
104     return $operations;
105   }
106
107   /**
108    * {@inheritdoc}
109    */
110   public function onQueuePreSave(EntityQueueInterface $queue, EntityStorageInterface $storage) {}
111
112   /**
113    * {@inheritdoc}
114    */
115   public function onQueuePostSave(EntityQueueInterface $queue, EntityStorageInterface $storage, $update = TRUE) {}
116
117   /**
118    * {@inheritdoc}
119    */
120   public function onQueuePreDelete(EntityQueueInterface $queue, EntityStorageInterface $storage) {}
121
122   /**
123    * {@inheritdoc}
124    */
125   public function onQueuePostDelete(EntityQueueInterface $queue, EntityStorageInterface $storage) {}
126
127   /**
128    * {@inheritdoc}
129    */
130   public function onQueuePostLoad(EntityQueueInterface $queue, EntityStorageInterface $storage) {}
131
132 }