You are here

function adsense_revenue_sharing_basic_get_node_info in Google AdSense integration 8

Provide the node type and the User ID of the author of the current page.

Return value

array|null User ID of author, or NULL if it wasn't possible to discover one.

1 call to adsense_revenue_sharing_basic_get_node_info()
adsense_revenue_sharing_basic_choose_client in oldcode/revenue_sharing_basic/adsense_revenue_sharing_basic.module
Provide the applicable Publisher ID, based on the configured probabilities.

File

oldcode/revenue_sharing_basic/adsense_revenue_sharing_basic.module, line 159
Main file of the adsense_revenue_sharing_basic module.

Code

function adsense_revenue_sharing_basic_get_node_info() {
  static $info = [];
  if (!$info) {
    $node = Drupal::routeMatch()
      ->getParameter('node');

    /** @var \Drupal\node\NodeInterface $node */
    if ($node instanceof NodeInterface) {

      // Cache the results.
      $info = [
        'uid' => $node
          ->getRevisionUser()
          ->id(),
        'type' => $node
          ->bundle(),
      ];
    }
    else {
      return NULL;
    }
  }
  return $info;
}