You are here

class EventInviteSettingsForm in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm
  2. 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm
  3. 10.1.x modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm
  4. 10.2.x modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm

Class EnrollInviteForm.

Hierarchy

Expanded class hierarchy of EventInviteSettingsForm

1 string reference to 'EventInviteSettingsForm'
social_event_invite.routing.yml in modules/social_features/social_event/modules/social_event_invite/social_event_invite.routing.yml
modules/social_features/social_event/modules/social_event_invite/social_event_invite.routing.yml

File

modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php, line 12

Namespace

Drupal\social_event_invite\Form
View source
class EventInviteSettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'enroll_invite_email_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $social_event_config = $this->configFactory
      ->getEditable('social_event_invite.settings');

    // Add an introduction text to explain what can be done here.
    $form['introduction']['warning'] = [
      '#type' => 'html_tag',
      '#tag' => 'p',
      '#value' => $this
        ->t('Be aware that when disabling invites altogether or for a specific group type, the outstanding invites in question <em>are cancelled</em>. Invitees will no longer be able to use their invite link.'),
    ];
    $form['invite_enroll'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable invite enrollment to events'),
      '#description' => $this
        ->t('Enabling this feature provides the possibility to let event managers to invite people to their events.'),
      '#default_value' => $social_event_config
        ->get('invite_enroll'),
    ];
    $group_types = [];

    /** @var \Drupal\group\Entity\GroupType $group_type */
    foreach (GroupType::loadMultiple() as $group_type) {
      $group_types[$group_type
        ->id()] = $group_type
        ->label();
    }
    $form['invite_group_types'] = [
      '#type' => 'checkboxes',
      '#title' => $this
        ->t('Enable event invite per group type'),
      '#description' => $this
        ->t('Select the group types for which you want to enable the event invite feature.'),
      '#options' => $group_types,
      '#default_value' => $social_event_config
        ->get('invite_group_types'),
    ];
    $form['invite_subject'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Subject'),
      '#default_value' => $social_event_config
        ->get('invite_subject'),
      '#required' => TRUE,
    ];
    $form['invite_message'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Message'),
      '#default_value' => $social_event_config
        ->get('invite_message'),
      '#required' => TRUE,
    ];
    $form['invite_helper'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Helper'),
      '#default_value' => $social_event_config
        ->get('invite_helper'),
      '#required' => TRUE,
      '#rows' => '2',
    ];
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#button_type' => 'primary',
      '#button_level' => 'raised',
      '#value' => $this
        ->t('Save configuration'),
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this->configFactory
      ->getEditable('social_event_invite.settings');
    $config
      ->set('invite_enroll', $form_state
      ->getValue('invite_enroll'));
    $config
      ->set('invite_group_types', $form_state
      ->getValue('invite_group_types'));
    $config
      ->set('invite_message', $form_state
      ->getValue('invite_message'));
    $config
      ->set('invite_subject', $form_state
      ->getValue('invite_subject'));
    $config
      ->set('invite_helper', $form_state
      ->getValue('invite_helper'));
    $config
      ->save();
  }

  /**
   * Gets the configuration names that will be editable.
   */
  protected function getEditableConfigNames() {

    // @todo Implement getEditableConfigNames() method.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 18
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 16
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
EventInviteSettingsForm::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
EventInviteSettingsForm::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
EventInviteSettingsForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
EventInviteSettingsForm::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
EventInviteSettingsForm::validateForm public function Form validation handler. Overrides FormBase::validateForm
FormBase::$configFactory protected property The config factory. 3
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 3
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route.
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.