You are here

public function SiteHeaderBlock::__construct in Opigno dashboard 3.x

Overrides BlockPluginTrait::__construct

File

src/Plugin/Block/SiteHeaderBlock.php, line 81

Class

SiteHeaderBlock
The site header block.

Namespace

Drupal\opigno_dashboard\Plugin\Block

Code

public function __construct(AccountInterface $account, EntityTypeManagerInterface $entity_type_manager, RouteMatchInterface $route_match, UserStatisticsManager $user_stats_manager, MenuLinkTreeInterface $menu_tree, OpignoNotificationManager $notification_manager, PrivateMessageServiceInterface $pm_service, ...$default) {
  parent::__construct(...$default);
  $uid = (int) $account
    ->id();
  $this->isUserPage = $route_match
    ->getRouteName() === 'entity.user.canonical' && (int) $route_match
    ->getRawParameter('user') === $uid;
  $this->statsManager = $user_stats_manager;
  $this->menuTree = $menu_tree;
  $this->notificationsManager = $notification_manager;
  $this->pmService = $pm_service;
  try {
    $this->user = $entity_type_manager
      ->getStorage('user')
      ->load($uid);
  } catch (PluginNotFoundException|InvalidPluginDefinitionException $e) {
    watchdog_exception('opigno_dashboard_exception', $e);
  }
}