function DispatchForm::submitForm

Overrides FormInterface::submitForm

File

tests/modules/rules_test_event/src/Form/DispatchForm.php, line 75

Class

DispatchForm
Acquires input, wraps it in a Task object, and queues it for processing.

Namespace

Drupal\rules_test_event\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $choice = $form_state->getValue('event');
    var_dump($choice);
    switch ($choice) {
        case 0:
            $event = new PlainEvent();
            break;
        case 1:
            $event = new GenericEvent('Test subject', [
                'publicProperty' => 'public property',
                'protectedProperty' => 'protected property',
                'privateProperty' => 'private property',
            ]);
            break;
        case 2:
            $event = new GetterEvent();
            break;
    }
    $this->dispatcher
        ->dispatch($event, $event::EVENT_NAME);
}