Quota.php in Message 8
File
src/Plugin/MessagePurge/Quota.php
View source
<?php
namespace Drupal\message\Plugin\MessagePurge;
use Drupal\Core\Form\FormStateInterface;
use Drupal\message\MessagePurgeBase;
use Drupal\message\MessageTemplateInterface;
class Quota extends MessagePurgeBase {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['quota'] = [
'#type' => 'number',
'#min' => 1,
'#title' => $this
->t('Messages quota'),
'#description' => $this
->t('Maximal (approximate) amount of messages.'),
'#default_value' => $this->configuration['quota'],
'#tree' => FALSE,
];
return parent::buildConfigurationForm($form, $form_state);
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$this->configuration['quota'] = $form_state
->getValue('quota');
}
public function defaultConfiguration() {
return [
'quota' => 1000,
];
}
public function fetch(MessageTemplateInterface $template) {
$query = $this
->baseQuery($template);
$result = $query
->range($this->configuration['quota'], 1000000)
->execute();
return $result;
}
}
Classes
Name |
Description |
Quota |
Maximal (approximate) amount of messages. |