function CommentStatistics::__construct

Same name and namespace in other branches
  1. 11.x core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::__construct()
  2. 10 core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::__construct()
  3. 9 core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::__construct()
  4. 8.9.x core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::__construct()

Constructs the CommentStatistics service.

Parameters

\Drupal\Core\Database\Connection $database: The active database connection.

\Drupal\Core\Session\AccountInterface $currentUser: The current logged in user.

\Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager: The entity type manager.

\Drupal\Core\State\StateInterface $state: The state service.

\Drupal\Component\Datetime\TimeInterface $time: The time service.

\Drupal\Core\Database\Connection|null $database_replica: (Optional) the replica database connection.

File

core/modules/comment/src/CommentStatistics.php, line 46

Class

CommentStatistics
Service for storing and retrieving comment statistics.

Namespace

Drupal\comment

Code

public function __construct(protected Connection $database, protected AccountInterface $currentUser, protected EntityTypeManagerInterface $entityTypeManager, protected StateInterface $state, protected TimeInterface $time, ?Connection $database_replica = NULL) {
  $this->databaseReplica = $database_replica ?: $this->database;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.