BrightcoveCronSettingsForm.php in Brightcove Video Connect 8
File
src/Form/BrightcoveCronSettingsForm.php
View source
<?php
namespace Drupal\brightcove\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\ConfigFormBase;
class BrightcoveCronSettingsForm extends ConfigFormBase {
protected function getEditableConfigNames() {
return [
'brightcove.settings',
];
}
public function getFormId() {
return 'brightcove_cron_settings';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('brightcove.settings');
$form['disable_cron'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Disable cron'),
'#description' => $this
->t('Enabling this option will prevent a Brightcove-to-Drupal sync running from cron.'),
'#default_value' => $config
->get('disable_cron'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('brightcove.settings')
->set('disable_cron', $form_state
->getValue('disable_cron'))
->save();
parent::submitForm($form, $form_state);
}
}