You are here

public function UserStatisticsManager::__construct in Opigno statistics 3.x

UserStatisticsManager constructor.

Parameters

\Drupal\Core\Session\AccountInterface $account: The current user account.

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

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

\Drupal\Core\Datetime\DateFormatterInterface $date_formatter: The date formatter service.

\Drupal\Core\Access\CsrfTokenGenerator $csrf_token: The CSRF token generator service.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory service.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler service.

File

src/Services/UserStatisticsManager.php, line 111

Class

UserStatisticsManager
User statistics manager service definition.

Namespace

Drupal\opigno_statistics\Services

Code

public function __construct(AccountInterface $account, Connection $database, EntityTypeManagerInterface $entity_type_manager, DateFormatterInterface $date_formatter, CsrfTokenGenerator $csrf_token, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) {
  $this->database = $database;
  $this->account = $account;
  $this->currentUid = (int) $account
    ->id();
  $this->dateFormatter = $date_formatter;
  $this->csrfToken = $csrf_token;
  $config_set = (bool) $config_factory
    ->get('opigno_class.socialsettings')
    ->get('enable_social_features') ?? FALSE;
  $this->isSocialsEnabled = $module_handler
    ->moduleExists('opigno_social') && $config_set;
  try {
    $this->userModuleStatusStorage = $entity_type_manager
      ->getStorage('user_module_status');
    $this->termStorage = $entity_type_manager
      ->getStorage('taxonomy_term');
  } catch (PluginNotFoundException|InvalidPluginDefinitionException $e) {
    watchdog_exception('opigno_statistics_exception', $e);
  }
}