You are here

public function CustomSearchAd::getAdPlaceholder in Google AdSense integration 8

Return the ad placeholder.

Return value

array ad placeholder

Overrides AdsenseAdInterface::getAdPlaceholder

File

src/Plugin/AdsenseAd/CustomSearchAd.php, line 41

Class

CustomSearchAd
Provides an AdSense custom search engine form.

Namespace

Drupal\adsense\Plugin\AdsenseAd

Code

public function getAdPlaceholder() {
  if (!empty($this->slot)) {
    $client = PublisherId::get();
    $content = "CSE v1\ncx = partner-{$client}:{$this->slot}";
    return [
      '#content' => [
        '#markup' => nl2br($content),
      ],
      '#format' => 'Search Box',
    ];
  }
  return [];
}