TestTask.php in Webform Scheduled Tasks 8.2
File
tests/modules/webform_scheduled_tasks_test_types/src/Plugin/WebformScheduledTasks/Task/TestTask.php
View source
<?php
namespace Drupal\webform_scheduled_tasks_test_types\Plugin\WebformScheduledTasks\Task;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform_scheduled_tasks\Plugin\WebformScheduledTasks\TaskPluginBase;
class TestTask extends TaskPluginBase {
public function executeTask(\Iterator $submissions) {
\Drupal::messenger()
->addStatus('Run test_task ::executeTask');
foreach ($submissions as $submission) {
\Drupal::messenger()
->addStatus('Processed submission ' . $submission
->id());
}
}
public function onSuccess() {
\Drupal::messenger()
->addStatus('Run test_task ::onSuccess');
}
public function onFailure() {
\Drupal::messenger()
->addStatus('Run test_task ::onFailure');
}
public function defaultConfiguration() {
return parent::defaultConfiguration() + [
'test_option' => FALSE,
];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['test_option'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Test option'),
'#default_value' => $this
->getConfiguration()['test_option'],
];
return $form;
}
}