You are here

protected function PageContextService::buildNodeData in Simple Facebook Pixel 8

Builds node view content event data.

1 call to PageContextService::buildNodeData()
PageContextService::build in src/PageContextService.php
Builds events data.

File

src/PageContextService.php, line 110

Class

PageContextService
Class PageContextService.

Namespace

Drupal\simple_facebook_pixel

Code

protected function buildNodeData() {
  $node = $this->request->attributes
    ->get('node');
  if ($node instanceof NodeInterface) {
    $view_content_entities = array_values($this->configFactory
      ->get('view_content_entities'));
    if (in_array('node:' . $node
      ->bundle(), $view_content_entities)) {
      $data = [
        'content_name' => $node
          ->getTitle(),
        'content_type' => $node
          ->bundle(),
        'content_ids' => [
          $node
            ->id(),
        ],
      ];
      $this->pixelBuilder
        ->addEvent('ViewContent', $data);
    }
  }
}