class DeveloperSettingsForm in Apigee Edge 8
Provides a form for changing Developer related settings.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\apigee_edge\Form\DeveloperSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of DeveloperSettingsForm
3 files declare their use of DeveloperSettingsForm
- apigee_edge.module in ./
apigee_edge.module - Copyright 2018 Google Inc.
- DeveloperEmailUnique.php in src/
Plugin/ Validation/ Constraint/ DeveloperEmailUnique.php - EmailTest.php in tests/
src/ Functional/ EmailTest.php
1 string reference to 'DeveloperSettingsForm'
File
- src/
Form/ DeveloperSettingsForm.php, line 28
Namespace
Drupal\apigee_edge\FormView source
class DeveloperSettingsForm extends ConfigFormBase {
/**
* Allow to confirm email address with a verification email.
*
* @var string
*/
public const VERIFICATION_ACTION_VERIFY_EMAIL = 'verify_email';
/**
* Abort registration, display an error.
*
* @var string
*/
public const VERIFICATION_ACTION_DISPLAY_ERROR_ONLY = 'display_error_only';
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'apigee_edge.developer_settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'apigee_edge_developer_settings_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('apigee_edge.developer_settings');
$form['email_verification_on_registration'] = [
'#type' => 'fieldset',
'#title' => $this
->t('When a new user registers and the developer email address is already taken on Apigee Edge but not in Drupal'),
'#collapsible' => FALSE,
];
$form['email_verification_on_registration']['verification_action'] = [
'#type' => 'radios',
'#options' => [
self::VERIFICATION_ACTION_VERIFY_EMAIL => $this
->t('Display an error message and send a verification email with a link that allows user to register'),
self::VERIFICATION_ACTION_DISPLAY_ERROR_ONLY => $this
->t('Display only an error message to the user'),
],
'#default_value' => $config
->get('verification_action') ?: self::VERIFICATION_ACTION_DISPLAY_ERROR_ONLY,
];
$form['email_verification_on_registration']['verification_email_subject'] = [
'#type' => 'textfield',
'#title' => $this
->t('Verification email subject'),
'#default_value' => $config
->get('verification_email.subject'),
'#states' => [
'visible' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
'required' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
],
];
$form['email_verification_on_registration']['verification_email_body'] = [
// By default Drupal does not support HTML mails therefore this is
// just a simple textarea.
'#type' => 'textarea',
'#title' => $this
->t('Verification email content'),
'#description' => $this
->t('Available tokens: [site:name], [site:url], [user:display-name], [user:account-name], [user:mail], [site:login-url], [site:url-brief], [user:developer-email-verification-url]'),
'#default_value' => $config
->get('verification_email.body'),
'#rows' => 10,
'#states' => [
'visible' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
'required' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
],
'#after_build' => [
'apigee_edge_developer_settings_form_verification_email_body_after_build',
],
];
$form['email_verification_on_registration']['verification_token'] = [
'#type' => 'textfield',
'#title' => $this
->t('Verification token'),
'#description' => $this
->t('Query parameter in registration url that contains the verification token. Ex.: user/register?%token=1234567', [
'%token' => $config
->get('verification_token'),
]),
'#default_value' => $config
->get('verification_token'),
'#states' => [
'visible' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
'required' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
],
];
$form['email_verification_on_registration']['verification_token_expires'] = [
'#type' => 'number',
'#title' => $this
->t('Verification token expires'),
'#description' => $this
->t('Number of seconds after the verification token expires. Initially provided registration data by a user is cached until the same time.'),
'#default_value' => $config
->get('verification_token_expires'),
'#min' => 60,
'#states' => [
'visible' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
'required' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
],
];
$form['email_verification_on_registration']['verify_email_error_message'] = [
'#type' => 'text_format',
'#title' => $this
->t('Error message'),
'#description' => $this
->t('The error message on the form. Use <em>%email</em> token in message to display the email address.'),
'#format' => $config
->get('verify_email_error_message.format'),
'#default_value' => $config
->get('verify_email_error_message.value'),
'#states' => [
'visible' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
'required' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_VERIFY_EMAIL,
],
],
],
],
];
$form['email_verification_on_registration']['display_only_error_message_content'] = [
'#type' => 'text_format',
'#title' => $this
->t('Error message'),
'#description' => $this
->t('The error message on the form. Use <em>%email</em> token in message to display the email address.'),
'#format' => $config
->get('display_only_error_message_content.format'),
'#default_value' => $config
->get('display_only_error_message_content.value'),
'#states' => [
'visible' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_DISPLAY_ERROR_ONLY,
],
],
],
'required' => [
[
':input[name="verification_action"]' => [
'value' => self::VERIFICATION_ACTION_DISPLAY_ERROR_ONLY,
],
],
],
],
];
$form['email_verification_on_edit'] = [
'#type' => 'fieldset',
'#title' => $this
->t('When a Drupal user changes its email address and the email address is already taken on Apigee Edge but not in Drupal'),
'#collapsible' => FALSE,
];
$form['email_verification_on_edit']['user_edit_error_message'] = [
'#type' => 'text_format',
'#title' => $this
->t('Error message'),
'#description' => $this
->t('The error message on the form.'),
'#format' => $config
->get('user_edit_error_message.format'),
'#default_value' => $config
->get('user_edit_error_message.value'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->configFactory
->getEditable('apigee_edge.developer_settings')
->set('verification_action', $form_state
->getValue('verification_action'))
->set('display_only_error_message_content.value', $form_state
->getValue([
'display_only_error_message_content',
'value',
]))
->set('display_only_error_message_content.format', $form_state
->getValue([
'display_only_error_message_content',
'format',
]))
->set('verify_email_error_message.value', $form_state
->getValue([
'verify_email_error_message',
'value',
]))
->set('verify_email_error_message.format', $form_state
->getValue([
'verify_email_error_message',
'format',
]))
->set('verification_email.subject', $form_state
->getValue([
'verification_email_subject',
]))
->set('verification_email.body', $form_state
->getValue([
'verification_email_body',
]))
->set('verification_token', $form_state
->getValue([
'verification_token',
]))
->set('verification_token_expires', $form_state
->getValue([
'verification_token_expires',
]))
->set('user_edit_error_message.value', $form_state
->getValue([
'user_edit_error_message',
'value',
]))
->set('user_edit_error_message.format', $form_state
->getValue([
'user_edit_error_message',
'format',
]))
->save();
parent::submitForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
DeveloperSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
DeveloperSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
DeveloperSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
DeveloperSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
DeveloperSettingsForm:: |
public | constant | Abort registration, display an error. | |
DeveloperSettingsForm:: |
public | constant | Allow to confirm email address with a verification email. | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |