CasUserInteractionTestForm.php in CAS 8
File
tests/modules/cas_user_interaction_test/src/CasUserInteractionTestForm.php
View source
<?php
namespace Drupal\cas_user_interaction_test;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class CasUserInteractionTestForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$form['accept'] = [
'#type' => 'checkbox',
'#title' => "I agree with the 'Legal Notice'",
'#required' => TRUE,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'I agree',
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$cas_user_manager = \Drupal::service('cas.user_manager');
$tempstore = \Drupal::service('tempstore.private')
->get('cas_user_interaction_test');
$cas_user_manager
->login($tempstore
->get('property_bag'), $tempstore
->get('ticket'));
$form_state
->setRedirectUrl(Url::fromUserInput('/'));
}
public function getFormId() {
return 'cas_user_interaction_test_form';
}
}