You are here

abstract class ContentAdBase in Google AdSense integration 8

Base class for content AdsenseAd plugins.

Hierarchy

Expanded class hierarchy of ContentAdBase

3 files declare their use of ContentAdBase
adsense.module in ./adsense.module
Displays Google AdSense ads on Drupal pages.
ManagedAd.php in src/Plugin/AdsenseAd/ManagedAd.php
OldCodeAd.php in oldcode/src/Plugin/AdsenseAd/OldCodeAd.php

File

src/ContentAdBase.php, line 8

Namespace

Drupal\adsense
View source
abstract class ContentAdBase extends AdsenseAdBase {

  /**
   * Ad Format.
   *
   * @var string
   */
  protected $format;

  /**
   * Provides the width and height of the ad.
   *
   * @param string $format
   *   Format of the ad (usually WIDTHxHEIGHT).
   *
   * @return array|null
   *   Array with dimensions of the ad, or null if format is not a
   */
  public static function dimensions($format) {
    if (preg_match('!^(\\d+)x(\\d+)(?:_5)?$!', $format, $matches)) {
      return [
        $matches[1],
        $matches[2],
      ];
    }
    return NULL;
  }

  /**
   * Gets the ad format.
   *
   * @return string
   *   This ad's format.
   */
  public function getFormat() {
    return $this->format;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdsenseAdBase::$configFactory protected property Config factory.
AdsenseAdBase::$currentUser protected property Current user.
AdsenseAdBase::$moduleHandler protected property Module handler.
AdsenseAdBase::adsenseLanguages public static function List of available languages. Overrides AdsenseAdInterface::adsenseLanguages
AdsenseAdBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
AdsenseAdBase::createAd public static function Creates the ad object, as specified by the definitions in the parameter. Overrides AdsenseAdInterface::createAd
AdsenseAdBase::display public function Display ad HTML.
AdsenseAdBase::isDisabled public static function Check if ads display is disabled.
AdsenseAdBase::__construct public function Creates a new AdsenseAdBase instance. Overrides PluginBase::__construct 5
AdsenseAdInterface::adsenseAdFormats public static function This is the array that holds all ad formats. 3
AdsenseAdInterface::getAdContent public function Return the ad content. 5
AdsenseAdInterface::getAdPlaceholder public function Return the ad placeholder. 5
ContentAdBase::$format protected property Ad Format.
ContentAdBase::dimensions public static function Provides the width and height of the ad.
ContentAdBase::getFormat public function Gets the ad format.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.