You are here

public function OldCodeAd::__construct in Google AdSense integration 8

Creates a new AdsenseAdBase instance.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed|null $plugin_definition: The plugin implementation definition.

\Drupal\Core\Config\ConfigFactoryInterface|null $config_factory: The config factory.

\Drupal\Core\Extension\ModuleHandlerInterface|null $module_handler: The module handler.

\Drupal\Core\Session\AccountProxyInterface|null $current_user: The current user.

Overrides AdsenseAdBase::__construct

File

oldcode/src/Plugin/AdsenseAd/OldCodeAd.php, line 37

Class

OldCodeAd
Provides an AdSense old code ad unit.

Namespace

Drupal\adsense_oldcode\Plugin\AdsenseAd

Code

public function __construct(array $configuration, $plugin_id = '', $plugin_definition = NULL, $config_factory = NULL, $module_handler = NULL, $current_user = NULL) {
  parent::__construct($configuration, $plugin_id, $plugin_definition, $config_factory, $module_handler, $current_user);
  $fo = !empty($configuration['format']) ? $configuration['format'] : '';
  $st = !empty($configuration['style']) ? $configuration['style'] : 1;
  $ch = !empty($configuration['channel']) ? $configuration['channel'] : '';
  if ($st < 1 || $st > ADSENSE_OLDCODE_MAX_GROUPS) {

    // Default to 1 if an invalid style is supplied.
    $st = 1;
  }
  if (substr($fo, 0, 10) != 'Search Box' && !empty($fo)) {
    $this->format = $fo;
    $this->style = $st;
    $this->channel = $ch;
  }
}