You are here

SocialGroupSettings.php in Open Social 8.2

File

modules/social_features/social_group/src/Form/SocialGroupSettings.php
View source
<?php

namespace Drupal\social_group\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Class SocialGroupSettings.
 *
 * @package Drupal\social_event_managers\Form
 */
class SocialGroupSettings extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'social_group.settings',
    ];
  }

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

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this
      ->config('social_group.settings');
    $form['allow_group_selection_in_node'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Allow logged-in users to change or remove a group when editing content'),
      '#description' => $this
        ->t('When checked, logged-in users can also move content to or out of a group after the content is created. Users can only move content to a group the author is a member of.'),
      '#default_value' => $config
        ->get('allow_group_selection_in_node'),
    ];
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $this
      ->config('social_group.settings')
      ->set('allow_group_selection_in_node', $form_state
      ->getValue('allow_group_selection_in_node'))
      ->save();
  }

}

Classes

Namesort descending Description
SocialGroupSettings Class SocialGroupSettings.