YandexMetricsReportsCronForm.php in Yandex.Metrics 8.2
File
yandex_metrics_reports/src/Form/YandexMetricsReportsCronForm.php
View source
<?php
namespace Drupal\yandex_metrics_reports\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class YandexMetricsReportsCronForm extends ConfigFormBase {
public function getFormID() {
return 'yandex_metrics_reports_cron_form';
}
protected function getEditableConfigNames() {
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->configFactory
->get('yandex_metrics_reports.settings');
$form['popular_content'] = array(
'#type' => 'fieldset',
'#title' => t('Popular Content Block Data'),
);
$options = array(
'day' => t('Today'),
'yesterday' => t('Yesterday'),
'week' => t('Week'),
'month' => t('Month'),
);
$form['popular_content']['date_period'] = array(
'#type' => 'select',
'#title' => t('Date period'),
'#description' => t('This date period is used to fetch popular content from Yandex.Metrica by cron.'),
'#options' => $options,
'#default_value' => $config
->get('popular_content_date_period'),
);
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory
->get('yandex_metrics_reports.settings');
$config
->set('popular_content_date_period', $form_state['values']['date_period'])
->save();
parent::submitForm($form, $form_state);
}
}