You are here

public function Days::fetch in Message 8

Fetch the messages that need to be purged for a given template.

Parameters

\Drupal\message\MessageTemplateInterface $template: The message template to fetch messages for.

Return value

array An array of \Drupal\message\MessageInterface entity IDs.

Overrides MessagePurgeInterface::fetch

File

src/Plugin/MessagePurge/Days.php, line 104

Class

Days
Delete messages older than certain days.

Namespace

Drupal\message\Plugin\MessagePurge

Code

public function fetch(MessageTemplateInterface $template) {
  $query = $this
    ->baseQuery($template);

  // Find messages older than the current time minus the maximum age.
  $earlier_than = $this->requestStack
    ->getCurrentRequest()->server
    ->get('REQUEST_TIME') - $this->configuration['days'] * 86400;
  $result = $query
    ->condition('created', $earlier_than, '<')
    ->execute();
  return $result;
}