class LearningPathAdminSettingsForm in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Form/LearningPathAdminSettingsForm.php \Drupal\opigno_learning_path\Form\LearningPathAdminSettingsForm
Class LearningPathAdminSettingsForm.
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\opigno_learning_path\Form\LearningPathAdminSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of LearningPathAdminSettingsForm
1 string reference to 'LearningPathAdminSettingsForm'
File
- src/
Form/ LearningPathAdminSettingsForm.php, line 11
Namespace
Drupal\opigno_learning_path\FormView source
class LearningPathAdminSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'opigno_learning_path.learning_path_settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'learning_path_admin_settings_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$tokens_description = [
'#type' => 'container',
[
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => t('Group tokens:'),
],
[
'#theme' => 'item_list',
'#list_type' => 'ul',
'#items' => [
'[group] - ' . $this
->t('group name'),
'[link] - ' . $this
->t('link to group'),
'[user] - ' . $this
->t('user account name'),
'[user-role] - ' . $this
->t('user role in group'),
'[user-status] - ' . $this
->t('user current status'),
],
],
];
$config = $this
->config('opigno_learning_path.learning_path_settings');
$form['opigno_learning_path_mail'] = [
'#type' => 'fieldset',
'#title' => $this
->t('E-mail notifications settings'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_admin'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Notify administrators'),
'#description' => $this
->t('If checked administrators will be notified on trainings updates.'),
'#default_value' => $config
->get('opigno_learning_path_notify_admin'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_mails'] = [
'#type' => 'textarea',
'#title' => $this
->t('Administrators email list.'),
'#default_value' => $config
->get('opigno_learning_path_notify_admin_mails'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_user_subscribed'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to admins when user subscribed/updated/removed'),
'#default_value' => $config
->get('opigno_learning_path_notify_admin_user_subscribed'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_user_approval'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to admins when user awaiting approval'),
'#default_value' => $config
->get('opigno_learning_path_notify_admin_user_approval'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_user_blocked'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to admins when user blocked'),
'#default_value' => $config
->get('opigno_learning_path_notify_admin_user_blocked'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_group_tokens_1'] = $tokens_description;
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$form['opigno_learning_path_mail']['token_tree_1'] = [
'#theme' => 'token_tree_link',
'#show_restricted' => TRUE,
];
}
$form['opigno_learning_path_mail']['opigno_learning_path_notify_users'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Notify users'),
'#description' => $this
->t('If checked users will be notified on training updates.'),
'#default_value' => $config
->get('opigno_learning_path_notify_users'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_subscribed'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to user when he subscribed/updated/removed'),
'#default_value' => $config
->get('opigno_learning_path_notify_user_user_subscribed'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_approval'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to user when he awaiting approval'),
'#default_value' => $config
->get('opigno_learning_path_notify_user_user_approval'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_blocked'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to user when he blocked'),
'#default_value' => $config
->get('opigno_learning_path_notify_user_user_blocked'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_group_tokens_2'] = $tokens_description;
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$form['opigno_learning_path_mail']['token_tree_2'] = [
'#theme' => 'token_tree_link',
'#show_restricted' => TRUE,
];
}
$form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_certificate_expired'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to user when a training certificate has expired'),
'#default_value' => $config
->get('opigno_learning_path_notify_user_user_certificate_expired'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_notify_group_tokens_3'] = [
'#type' => 'container',
[
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => t('Group tokens:'),
],
[
'#theme' => 'item_list',
'#list_type' => 'ul',
'#items' => [
'[group:title] - ' . $this
->t('group name'),
'[group:url] - ' . $this
->t('link to group'),
'[group:expiration_date] - ' . $this
->t('certificate expiration date'),
],
],
];
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$form['opigno_learning_path_mail']['token_tree_3'] = [
'#theme' => 'token_tree_link',
'#token_types' => [
'group',
],
'#show_restricted' => TRUE,
];
}
$form['opigno_learning_path_mail']['opigno_learning_path_student_does_activity_notify'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Notify manager'),
'#description' => $this
->t('If checked a manager will be notified when student does an activity.'),
'#default_value' => $config
->get('opigno_learning_path_student_does_activity_notify'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_student_does_activity'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to a manager when student does an activity.'),
'#default_value' => $config
->get('opigno_learning_path_student_does_activity'),
];
$form['opigno_learning_path_mail']['student_does_activity_tokens'] = [
'#type' => 'container',
[
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => t('Tokens:'),
],
[
'#theme' => 'item_list',
'#list_type' => 'ul',
'#items' => [
'[module] - ' . $this
->t('module name'),
'[link] - ' . $this
->t('link to evaluate'),
'[manager] - ' . $this
->t('manager name'),
'[user] - ' . $this
->t('user name'),
'[sitename] - ' . $this
->t('site name'),
],
],
];
$form['opigno_learning_path_mail']['opigno_learning_path_students_answer_is_reviewed_notify'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Notify student'),
'#description' => $this
->t('If checked a student will be notified when student does an activity.'),
'#default_value' => $config
->get('opigno_learning_path_students_answer_is_reviewed_notify'),
];
$form['opigno_learning_path_mail']['opigno_learning_path_students_answer_is_reviewed'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to a student when his answer has been reviewed.'),
'#default_value' => $config
->get('opigno_learning_path_students_answer_is_reviewed'),
];
$form['opigno_learning_path_mail']['students_answer_is_reviewed_tokens'] = [
'#type' => 'container',
[
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => t('Tokens:'),
],
[
'#theme' => 'item_list',
'#list_type' => 'ul',
'#items' => [
'[module] - ' . $this
->t('module name'),
'[manager] - ' . $this
->t('manager name'),
'[user] - ' . $this
->t('user name'),
'[sitename] - ' . $this
->t('site name'),
],
],
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('opigno_learning_path.learning_path_settings')
->set('opigno_learning_path_notify_admin', $form_state
->getValue('opigno_learning_path_notify_admin'))
->set('opigno_learning_path_notify_admin_mails', $form_state
->getValue('opigno_learning_path_notify_admin_mails'))
->set('opigno_learning_path_notify_users', $form_state
->getValue('opigno_learning_path_notify_users'))
->set('opigno_learning_path_notify_admin_user_subscribed', $form_state
->getValue('opigno_learning_path_notify_admin_user_subscribed'))
->set('opigno_learning_path_notify_admin_user_approval', $form_state
->getValue('opigno_learning_path_notify_admin_user_approval'))
->set('opigno_learning_path_notify_admin_user_blocked', $form_state
->getValue('opigno_learning_path_notify_admin_user_blocked'))
->set('opigno_learning_path_notify_user_user_subscribed', $form_state
->getValue('opigno_learning_path_notify_user_user_subscribed'))
->set('opigno_learning_path_notify_user_user_approval', $form_state
->getValue('opigno_learning_path_notify_user_user_approval'))
->set('opigno_learning_path_notify_user_user_blocked', $form_state
->getValue('opigno_learning_path_notify_user_user_blocked'))
->set('opigno_learning_path_notify_user_user_certificate_expired', $form_state
->getValue('opigno_learning_path_notify_user_user_certificate_expired'))
->set('opigno_learning_path_student_does_activity_notify', $form_state
->getValue('opigno_learning_path_student_does_activity_notify'))
->set('opigno_learning_path_student_does_activity', $form_state
->getValue('opigno_learning_path_student_does_activity'))
->set('opigno_learning_path_students_answer_is_reviewed_notify', $form_state
->getValue('opigno_learning_path_students_answer_is_reviewed_notify'))
->set('opigno_learning_path_students_answer_is_reviewed', $form_state
->getValue('opigno_learning_path_students_answer_is_reviewed'))
->save();
}
}
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 | |
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. | |
LearningPathAdminSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
LearningPathAdminSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
LearningPathAdminSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
LearningPathAdminSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
LearningPathAdminSettingsForm:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
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. |