You are here

public function Logger::eventCollection in MongoDB 8.2

Return a collection, given its template id.

Parameters

string $templateId: The string representation of a template \MongoId.

Return value

\MongoDB\Collection A collection object for the specified template id.

3 calls to Logger::eventCollection()
Logger::log in modules/mongodb_watchdog/src/Logger.php
Logger::requestEvents in modules/mongodb_watchdog/src/Logger.php
Return the events having occurred during a given request.
Logger::requestEventsCount in modules/mongodb_watchdog/src/Logger.php
Count events matching a request unique_id.

File

modules/mongodb_watchdog/src/Logger.php, line 587

Class

Logger
Class Logger is a PSR/3 Logger using a MongoDB data store.

Namespace

Drupal\mongodb_watchdog

Code

public function eventCollection($templateId) : Collection {
  $name = static::EVENT_COLLECTION_PREFIX . $templateId;
  if (!preg_match('/' . static::EVENT_COLLECTIONS_PATTERN . '/', $name)) {
    throw new InvalidArgumentException(new FormattableMarkup('Invalid watchdog template id `@id`.', [
      '@id' => $name,
    ]));
  }
  $collection = $this->database
    ->selectCollection($name);
  return $collection;
}