Adsense.php in Thunder 8.4
File
src/Plugin/Thunder/OptionalModule/Adsense.php
View source
<?php
namespace Drupal\thunder\Plugin\Thunder\OptionalModule;
use Drupal\Core\Form\FormStateInterface;
class Adsense extends AbstractOptionalModule {
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$form['adsense']['adsense_basic_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Site Google AdSense Publisher ID'),
'#required' => FALSE,
'#default_value' => '',
'#pattern' => 'pub-[0-9]+',
'#description' => $this
->t('This is the Google AdSense Publisher ID for the site owner. It is used if no other ID is suitable. Get this in your Google Adsense account. It should be similar to %id.', [
'%id' => 'pub-9999999999999',
]),
];
return $form;
}
public function submitForm(array $formValues) {
$this->configFactory
->getEditable('adsense.settings')
->set('adsense_basic_id', (string) $formValues['adsense_basic_id'])
->save(TRUE);
}
}