You are here

public function TawkToEmbedRender::__construct in Tawk.to - Live chat application (Drupal 8) 8

Same name and namespace in other branches
  1. 8.2 src/Service/TawkToEmbedRender.php \Drupal\tawk_to\Service\TawkToEmbedRender::__construct()

Constructs the TawkToEmbedRender.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $configFactory: The factory for configuration objects.

\Drupal\Core\Utility\Token $token: The token service.

Drupal\tawk_to\Service\TawkToConditionPluginsHandler $conditionPluginsHandler: The tawk.to access controller handler.

Drupal\tawk_to\Cache\TawkToCacheManager $cacheManager: The cache manager.

File

src/Service/TawkToEmbedRender.php, line 73

Class

TawkToEmbedRender
Defines the rendering tawk.to service.

Namespace

Drupal\tawk_to\Service

Code

public function __construct(ConfigFactoryInterface $configFactory, Token $token, TawkToConditionPluginsHandler $conditionPluginsHandler, TawkToCacheManager $cacheManager) {
  $this->conditionPluginsHandler = $conditionPluginsHandler;
  $this->cacheManager = $cacheManager;
  $this->widgetPageId = $configFactory
    ->get('tawk_to.settings')
    ->get('tawk_to_widget_page_id');
  $this->widgetId = $configFactory
    ->get('tawk_to.settings')
    ->get('tawk_to_widget_id');
  if ($configFactory
    ->get('tawk_to.settings')
    ->get('show_user_name')) {
    $userName = $configFactory
      ->get('tawk_to.settings')
      ->get('user_name');
    $this->userName = $token
      ->replace($userName, [], [
      'clear' => TRUE,
    ]);
  }
  if ($configFactory
    ->get('tawk_to.settings')
    ->get('show_user_email')) {
    $userEmail = $configFactory
      ->get('tawk_to.settings')
      ->get('user_email');
    $this->userEmail = $token
      ->replace($userEmail, [], [
      'clear' => TRUE,
    ]);
  }
}