5 * Contains \Drupal\security_review\Form\RunForm.
8 namespace Drupal\security_review\Form;
10 use Drupal\Core\Form\FormBase;
11 use Drupal\Core\Form\FormStateInterface;
12 use Drupal\security_review\Checklist;
13 use Symfony\Component\DependencyInjection\ContainerInterface;
16 * Provides implementation for the Run form.
18 class RunForm extends FormBase {
21 * The security_review.checklist service.
23 * @var \Drupal\security_review\Checklist
28 * Constructs a RunForm.
30 * @param \Drupal\security_review\Checklist $checklist
31 * The security_review.checklist service.
33 public function __construct(Checklist $checklist) {
34 $this->checklist = $checklist;
40 public static function create(ContainerInterface $container) {
42 $container->get('security_review.checklist')
49 public function getFormId() {
50 return 'security-review-run';
56 public function buildForm(array $form, FormStateInterface $form_state) {
57 if (!$this->currentUser()->hasPermission('run security checks')) {
63 '#title' => $this->t('Run'),
64 '#description' => $this->t('Click the button below to run the security checklist and review the results.') . '<br />',
68 $form['run_form']['submit'] = [
70 '#value' => $this->t('Run checklist'),
73 // Return the finished form.
80 public function submitForm(array &$form, FormStateInterface $form_state) {
83 'finished' => '_security_review_batch_run_finished',
84 'title' => $this->t('Performing Security Review'),
85 'init_message' => $this->t('Security Review is starting.'),
86 'progress_message' => $this->t('Progress @current out of @total.'),
87 'error_message' => $this->t('An error occurred. Rerun the process or consult the logs.'),
90 foreach ($this->checklist->getEnabledChecks() as $check) {
91 $batch['operations'][] = [
92 '_security_review_batch_run_op',