class SocialGroupQuickjoinSettings in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 8.4 modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 8.5 modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 8.7 modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 8.8 modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 10.3.x modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 10.0.x modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 10.1.x modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- 10.2.x modules/social_features/social_group/modules/social_group_quickjoin/src/Form/SocialGroupQuickjoinSettings.php \Drupal\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
Class SocialEventTypeSettings.
@package Drupal\social_group_quickjoin\Form
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\social_group_quickjoin\Form\SocialGroupQuickjoinSettings
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of SocialGroupQuickjoinSettings
1 string reference to 'SocialGroupQuickjoinSettings'
- social_group_quickjoin.routing.yml in modules/
social_features/ social_group/ modules/ social_group_quickjoin/ social_group_quickjoin.routing.yml - modules/social_features/social_group/modules/social_group_quickjoin/social_group_quickjoin.routing.yml
File
- modules/
social_features/ social_group/ modules/ social_group_quickjoin/ src/ Form/ SocialGroupQuickjoinSettings.php, line 14
Namespace
Drupal\social_group_quickjoin\FormView source
class SocialGroupQuickjoinSettings extends ConfigFormBase {
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'social_group_quickjoin.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'social_group_quickjoin_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('social_group_quickjoin.settings');
$form['help'] = [
'#type' => 'item',
'#markup' => $this
->t("Enabling this feature gives site builders the possibility to create group 'quick join' links (ex., /group/1/quickjoin). Furthermore, it's possible to skip the confirmation step on a group type basis."),
];
$form['social_group_quickjoin_enabled'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Enable quickjoin"),
'#description' => $this
->t("Allow users to join groups with a single click."),
'#default_value' => $config
->get('social_group_quickjoin_enabled'),
];
$form['grouptypes'] = [
'#type' => 'details',
'#title' => $this
->t('Group types'),
'#open' => TRUE,
'#states' => [
'visible' => [
':input[name="social_group_quickjoin_enabled"]' => [
'checked' => TRUE,
],
],
],
];
/** @var \Drupal\group\Entity\GroupType $group_type */
foreach ($this
->getGroups() as $group_type) {
// The setting name.
$setting_name = 'social_group_quickjoin_' . $group_type
->id();
$form['grouptypes'][$setting_name] = [
'#type' => 'checkbox',
'#title' => $this
->t('Skip confirmation for type @grouptype', [
'@grouptype' => $group_type
->label(),
]),
'#description' => $this
->t('Allow users to skip the confirmation step when joining any @grouptype.', [
'@grouptype' => $group_type
->label(),
]),
'#default_value' => $config
->get($setting_name),
];
}
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
// Set the value for the general setting.
$this
->config('social_group_quickjoin.settings')
->set('social_group_quickjoin_enabled', $form_state
->getValue('social_group_quickjoin_enabled'))
->save();
/** @var \Drupal\group\Entity\GroupType $group_type */
foreach ($this
->getGroups() as $group_type) {
// The setting name.
$setting_name = 'social_group_quickjoin_' . $group_type
->id();
$setting_value = $form_state
->getValue('social_group_quickjoin_enabled') ? $form_state
->getValue($setting_name) : FALSE;
// Set the value in the config.
$this
->config('social_group_quickjoin.settings')
->set($setting_name, $setting_value);
}
// Save the config.
$this
->config('social_group_quickjoin.settings')
->save();
}
/**
* Function that returns all groups that outsider can become a member of.
*
* @return array
* Joinable groups.
*/
protected function getGroups() {
$types = [];
/** @var \Drupal\group\Entity\GroupType $group_type */
foreach (GroupType::loadMultiple() as $group_type) {
// We can only select group types that have the 'join group'
// permission enabled.
if (in_array('join group', $group_type
->getOutsiderRole()
->getPermissions())) {
$types[] = $group_type;
}
}
return $types;
}
}
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. | |
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. | |
SocialGroupQuickjoinSettings:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
SocialGroupQuickjoinSettings:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
SocialGroupQuickjoinSettings:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
SocialGroupQuickjoinSettings:: |
protected | function | Function that returns all groups that outsider can become a member of. | |
SocialGroupQuickjoinSettings:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
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. |