You are here

protected function GoogleAnalyticsEventTracking::contentTypeMatch in Google Analytics Event Tracking 8

Same name and namespace in other branches
  1. 8.2 src/GoogleAnalyticsEventTracking.php \Drupal\google_analytics_et\GoogleAnalyticsEventTracking::contentTypeMatch()

Evaluates whether the tracker is effective for the current content type.

Parameters

\Drupal\google_analytics_et\Entity\GoogleAnalyticsEventTrackerInterface $tracker:

Return value

bool

1 call to GoogleAnalyticsEventTracking::contentTypeMatch()
GoogleAnalyticsEventTracking::isTrackerActive in src/GoogleAnalyticsEventTracking.php
Evaluates whether the provided event tracker is active in current context.

File

src/GoogleAnalyticsEventTracking.php, line 162

Class

GoogleAnalyticsEventTracking

Namespace

Drupal\google_analytics_et

Code

protected function contentTypeMatch(GoogleAnalyticsEventTrackerInterface $tracker) {
  $content_types = $tracker
    ->get('content_types');
  if (empty($content_types)) {
    return TRUE;
  }

  /** @var \Drupal\node\NodeInterface $node */
  if ($node = $this->currentRouteMatch
    ->getParameter('node')) {
    foreach ($content_types as $key => $content_type) {
      if ($content_type == $node
        ->getType()) {
        return TRUE;
      }
    }
  }
  return FALSE;
}