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