You are here

class Quota in Message 8

Maximal (approximate) amount of messages.

Plugin annotation


@MessagePurge(
  id = "quota",
  label = @Translation("Quota", context = "MessagePurge"),
  description = @Translation("Maximal (approximate) amount of messages to keep."),
)

Hierarchy

Expanded class hierarchy of Quota

1 string reference to 'Quota'
message.schema.yml in config/schema/message.schema.yml
config/schema/message.schema.yml

File

src/Plugin/MessagePurge/Quota.php, line 18

Namespace

Drupal\message\Plugin\MessagePurge
View source
class Quota extends MessagePurgeBase {

  /**
   * {@inheritdoc}
   */
  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);
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);
    $this->configuration['quota'] = $form_state
      ->getValue('quota');
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'quota' => 1000,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function fetch(MessageTemplateInterface $template) {
    $query = $this
      ->baseQuery($template);
    $result = $query
      ->range($this->configuration['quota'], 1000000)
      ->execute();
    return $result;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MessagePurgeBase::$messageQuery protected property The entity query object for Message items.
MessagePurgeBase::$queue protected property The message deletion queue.
MessagePurgeBase::$weight protected property The weight of the purge plugin.
MessagePurgeBase::baseQuery protected function Get a base query.
MessagePurgeBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 1
MessagePurgeBase::description public function Returns the purge method description. Overrides MessagePurgeInterface::description
MessagePurgeBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
MessagePurgeBase::getWeight public function Returns the weight of the purge plugin. Overrides MessagePurgeInterface::getWeight
MessagePurgeBase::label public function Returns the purge method label. Overrides MessagePurgeInterface::label
MessagePurgeBase::process public function Process the purgeable messages. Overrides MessagePurgeInterface::process
MessagePurgeBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
MessagePurgeBase::setWeight public function Sets the weight for this purge plugin. Overrides MessagePurgeInterface::setWeight
MessagePurgeBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
MessagePurgeBase::__construct public function Constructs a MessagePurgeBase object. Overrides PluginBase::__construct 1
MessagePurgeInterface::MESSAGE_DELETE_SIZE constant The maximum number of messages that a queue worker should delete at once.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
Quota::buildConfigurationForm public function Form constructor. Overrides MessagePurgeBase::buildConfigurationForm
Quota::defaultConfiguration public function Gets default configuration for this plugin. Overrides ConfigurableInterface::defaultConfiguration
Quota::fetch public function Fetch the messages that need to be purged for a given template. Overrides MessagePurgeInterface::fetch
Quota::submitConfigurationForm public function Form submission handler. Overrides MessagePurgeBase::submitConfigurationForm
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.