class SocialAddToCalendarSettingsForm in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_addtocal/src/Form/SocialAddToCalendarSettingsForm.php \Drupal\social_event_addtocal\Form\SocialAddToCalendarSettingsForm
- 10.3.x modules/social_features/social_event/modules/social_event_addtocal/src/Form/SocialAddToCalendarSettingsForm.php \Drupal\social_event_addtocal\Form\SocialAddToCalendarSettingsForm
- 10.1.x modules/social_features/social_event/modules/social_event_addtocal/src/Form/SocialAddToCalendarSettingsForm.php \Drupal\social_event_addtocal\Form\SocialAddToCalendarSettingsForm
- 10.2.x modules/social_features/social_event/modules/social_event_addtocal/src/Form/SocialAddToCalendarSettingsForm.php \Drupal\social_event_addtocal\Form\SocialAddToCalendarSettingsForm
Class SocialAddToCalendarSettingsForm.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\social_event_addtocal\Form\SocialAddToCalendarSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of SocialAddToCalendarSettingsForm
1 string reference to 'SocialAddToCalendarSettingsForm'
- social_event_addtocal.routing.yml in modules/
social_features/ social_event/ modules/ social_event_addtocal/ social_event_addtocal.routing.yml - modules/social_features/social_event/modules/social_event_addtocal/social_event_addtocal.routing.yml
File
- modules/
social_features/ social_event/ modules/ social_event_addtocal/ src/ Form/ SocialAddToCalendarSettingsForm.php, line 14
Namespace
Drupal\social_event_addtocal\FormView source
class SocialAddToCalendarSettingsForm extends ConfigFormBase {
/**
* Add to calendar plugin manager.
*
* @var \Drupal\social_event_addtocal\Plugin\SocialAddToCalendarManager
*/
protected $addToCalendarManager;
/**
* SocialAddToCalendarSettingsForm constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\social_event_addtocal\Plugin\SocialAddToCalendarManager $add_to_calendar_manager
* Add to calendar plugin manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, SocialAddToCalendarManager $add_to_calendar_manager) {
parent::__construct($config_factory);
$this->addToCalendarManager = $add_to_calendar_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('plugin.manager.social_add_to_calendar'));
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'social_event_addtocal.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'social_add_to_calendar_settings_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('social_event_addtocal.settings');
// Enable the 'Add to calendar' feature.
$form['enable_add_to_calendar'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable the <em>Add to calendar</em> button'),
'#description' => $this
->t('If enabled, logged-in users are allowed to add the event to own calendar'),
'#default_value' => $config
->get('enable_add_to_calendar'),
];
// Get all calendar plugins and generate options.
$addtocal_options = [];
$addtocal_definitions = $this->addToCalendarManager
->getDefinitions();
foreach ($addtocal_definitions as $addtocal_definition) {
$addtocal_options[$addtocal_definition['id']] = $addtocal_definition['label'];
}
// Allowed calendars.
$form['allowed_calendars'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Allowed calendars'),
'#description' => $this
->t('Enable calendars you want to allow users to use'),
'#options' => $addtocal_options,
'#states' => [
'visible' => [
':input[name="enable_add_to_calendar"]' => [
'checked' => TRUE,
],
],
],
'#default_value' => $config
->get('allowed_calendars') ?: [],
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('social_event_addtocal.settings')
->set('enable_add_to_calendar', $form_state
->getValue('enable_add_to_calendar'))
->set('allowed_calendars', $form_state
->getValue('allowed_calendars'))
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 3 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 3 |
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. | |
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:: |
72 |
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. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
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. | |
SocialAddToCalendarSettingsForm:: |
protected | property | Add to calendar plugin manager. | |
SocialAddToCalendarSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
SocialAddToCalendarSettingsForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
SocialAddToCalendarSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
SocialAddToCalendarSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
SocialAddToCalendarSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
SocialAddToCalendarSettingsForm:: |
public | function |
SocialAddToCalendarSettingsForm constructor. Overrides ConfigFormBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |