You are here

public function EventController::find in MongoDB 8.2

Load MongoDB watchdog events for a given event template.

Parameters

\Drupal\mongodb_watchdog\EventTemplate $template: The template for which to find events.

string $skip: The string representation of the number of events to skip.

int $limit: The limit on the number of events to return.

Return value

\MongoDB\Driver\Cursor A cursor to the event occurrences.

File

modules/mongodb_watchdog/src/EventController.php, line 145

Class

EventController
Class EventController provides query and render logic for Event occurrences.

Namespace

Drupal\mongodb_watchdog

Code

public function find(EventTemplate $template, $skip, $limit) : Cursor {
  $collection = $this->watchdog
    ->eventCollection($template->_id);
  $selector = [];
  $options = [
    'skip' => $skip,
    'limit' => $limit,
    'sort' => [
      '$natural' => -1,
    ],
    'typeMap' => [
      'array' => 'array',
      'document' => 'array',
      'root' => 'Drupal\\mongodb_watchdog\\Event',
    ],
  ];
  $result = $collection
    ->find($selector, $options);
  return $result;
}