You are here

function prebid_preprocess_dfp_tag in Doubleclick for Publishers (DFP) 7.2

Implements hook_preprocess_HOOK().

File

prebid/prebid.module, line 109

Code

function prebid_preprocess_dfp_tag(&$variables) {
  $tag = $variables['tag'];
  $name = $tag->machinename;
  ctools_include('bidder', 'prebid');
  $bidders = prebid_get_bidders();
  foreach ($bidders as $bidder) {
    $class = ctools_plugin_get_class($bidder, 'handler');
    if ($class) {
      $plugin = new $class();
      $plugin
        ->init($bidder, $tag);
    }
    else {
      $plugin = new stdClass();
      $plugin->plugin = $bidder;
    }

    // No, this does not overwrite the dfpTags settings but rather merges them.
    $settings = array(
      'dfpTags' => array(
        $name => array(
          'bidderAdapters' => array(
            $plugin->plugin,
          ),
        ),
      ),
    );
    drupal_add_js($settings, 'setting');
  }
}