Skip to content

Commit

Permalink
adds AuthPromptDispatchForm
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonlarsson committed Aug 30, 2017
1 parent e797538 commit 879dc57
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 15 deletions.
2 changes: 1 addition & 1 deletion auth_prompt/auth_prompt.routing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
auth_prompt:
path: 'modules/auth_prompt'
defaults:
_title: 'Auth Promt'
_title: 'Auth Prompt'
requirements:
_permission: 'access content'
14 changes: 0 additions & 14 deletions auth_prompt/composer.json

This file was deleted.

55 changes: 55 additions & 0 deletions auth_prompt/src/Form/AuthPromptDispatchForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* @file
* Contains \Drupal\auth_prompt\Form\AuthPromptDispatchForm.
*/

namespace Drupal\auth_prompt\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\auth_prompt\AuthPrompt;

/**
* Class AuthPromptDispatchForm.
*
* @package Drupal\auth_prompt\Form
*/
class AuthPromptDispatchForm extends FormBase {

/**
* {@inheritdoc}
*/
public function getFormId() {
return 'auth_prompt_dispatch_form';
}

/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Reference'),
'#description' => $this->t('Authentication prompt to an anonymus user of the website.'),
'#maxlength' => 64,
'#size' => 64,
);
$form['dispatch'] = array(
'#type' => 'submit',
'#value' => $this->t('Dispatch'),
);
return $form;
}

/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// AuthPrompt Dispatching
$dispatcher = \Drupal::service('event_dispatcher');
$event = new AuthPrompt($form_state->getValue('name'));
$dispatcher->dispatch(AuthPrompt::SUBMIT, $event);
}
}

0 comments on commit 879dc57

Please sign in to comment.