You are here

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

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

Checks acess to the current requests and return renderable array or NULL.

Return value

array|null The render renderable array or NULL.

File

src/Service/TawkToEmbedRender.php, line 94

Class

TawkToEmbedRender
Defines the rendering tawk.to service.

Namespace

Drupal\tawk_to\Service

Code

public function render() {
  if ($this->widgetPageId === '' || $this->widgetId === '') {
    return NULL;
  }
  if ($this->conditionPluginsHandler
    ->checkAccess()) {
    return [
      '#theme' => 'tawk_to',
      '#items' => [
        'page_id' => $this->widgetPageId,
        'widget_id' => $this->widgetId,
        'embed_url' => self::EMBED_URL,
        'user_name' => $this->userName,
        'user_email' => $this->userEmail,
      ],
      '#cache' => [
        'contexts' => $this->cacheManager
          ->getCacheContexts(),
        'tags' => $this->cacheManager
          ->getCacheTags(),
      ],
    ];
  }
  return NULL;
}