public function AdsenseAdsTxtController::display in Google AdSense integration 8
Display the ads.txt page.
Return value
\Symfony\Component\HttpFoundation\Response Plain text response with the ads.txt content.
1 string reference to 'AdsenseAdsTxtController::display'
- adsense_adstxt.routing.yml in adstxt/
adsense_adstxt.routing.yml - adstxt/adsense_adstxt.routing.yml
File
- adstxt/
src/ Controller/ AdsenseAdsTxtController.php, line 49
Class
- AdsenseAdsTxtController
- Controller for the ads.txt file.
Namespace
Drupal\adsense_adstxt\ControllerCode
public function display() {
$client = PublisherId::get();
$this->moduleHandler
->alter('adsense', $client);
if (!empty($client)) {
$content = "google.com, {$client}, DIRECT, f08c47fec0942fa0\n";
return new Response($content, 200, [
'Content-Type' => 'text/plain',
]);
}
throw new NotFoundHttpException();
}