Skip to content

Commit

Permalink
Merge pull request #32 from wfp/develop
Browse files Browse the repository at this point in the history
Add cron checkbox
  • Loading branch information
lashab committed May 25, 2016
2 parents c8a9cc3 + 9b8f570 commit 845c236
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/install/html_auditor.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ html5:
errors_only: true
link:
report_verbose: true
cron:
enable: false
7 changes: 5 additions & 2 deletions html_auditor.module
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Implements hook_cron().
*/
function html_auditor_cron() {
// Run html auditor.
\Drupal::service('html_auditor')->run();
$config = \Drupal::config('html_auditor.settings');
if ($config->get('cron.enable')) {
// Run html auditor.
\Drupal::service('html_auditor')->run();
}
}
11 changes: 9 additions & 2 deletions src/Form/AuditorConfigurationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,18 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#default_value' => $config->get('link.report_verbose'),
'#prefix' => '<strong>Link audit</strong>',
];
$form['html_auditor']['cron'] = [
'#type' => 'checkbox',
'#title' => $this->t('Perform HTML audit on cron run'),
'#default_value' => $config->get('cron.enable'),
'#prefix' => '<strong>Cron</strong>',
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save configuration'),
'#button_type' => 'primary',
);
];
$form['actions']['run'] = [
'#type' => 'submit',
'#value' => $this->t('Perform audit'),
Expand All @@ -135,6 +141,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
->set('a11y.ignore', $values['a11y_ignore'])
->set('html5.errors_only', $values['html5_errors_only'])
->set('link.report_verbose', $values['link_report_verbose'])
->set('cron.enable', $values['cron'])
->save();

drupal_set_message($this->t('The configuration options have been saved.'));
Expand Down

0 comments on commit 845c236

Please sign in to comment.