function CommentStatistics::__construct
Same name in other branches
- 9 core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::__construct()
- 8.9.x core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::__construct()
- 11.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 $current_user: The current logged in user.
\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.
\Drupal\Core\State\StateInterface $state: The state service.
\Drupal\Component\Datetime\TimeInterface|null|\Drupal\Core\Database\Connection $time: The time service.
\Drupal\Core\Database\Connection|null $database_replica: (Optional) the replica database connection.
File
-
core/
modules/ comment/ src/ CommentStatistics.php, line 68
Class
Namespace
Drupal\commentCode
public function __construct(Connection $database, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager, StateInterface $state, TimeInterface|Connection|null $time = NULL, ?Connection $database_replica = NULL) {
$this->database = $database;
$this->currentUser = $current_user;
$this->entityTypeManager = $entity_type_manager;
$this->state = $state;
if (!$time || $time instanceof Connection) {
@trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and it will be the 4th argument in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
if ($time instanceof Connection) {
$database_replica = $time;
}
$this->time = \Drupal::service(TimeInterface::class);
}
$this->databaseReplica = $database_replica ?: $database;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.