SocialCommentUploadSettingsForm.php in Open Social 8.2
Same filename and directory in other branches
- 8.9 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 8 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 8.3 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 8.4 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 8.5 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 8.6 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 8.7 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 8.8 modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 10.3.x modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 10.0.x modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 10.1.x modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
- 10.2.x modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.php
Namespace
Drupal\social_comment_upload\FormFile
modules/social_features/social_comment_upload/src/Form/SocialCommentUploadSettingsForm.phpView source
<?php
namespace Drupal\social_comment_upload\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class SocialCommentUploadSettingsForm.
*
* @package Drupal\social_comment_upload\Form
*/
class SocialCommentUploadSettingsForm extends ConfigFormBase implements ContainerInjectionInterface {
/**
* The Module Handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* {@inheritdoc}
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler) {
parent::__construct($config_factory);
$this->moduleHandler = $moduleHandler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('module_handler'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'social_comment_upload_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'social_comment_upload.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// Get the configuration file.
$config = $this
->config('social_comment_upload.settings');
$form['allow_upload_comments'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Allow file uploads in comments.'),
'#default_value' => $config
->get('allow_upload_comments'),
'#required' => FALSE,
'#description' => $this
->t("Determine wether users can upload documents to comments."),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Get the configuration file.
$config = $this
->config('social_comment_upload.settings');
$config
->set('allow_upload_comments', $form_state
->getValue('allow_upload_comments'))
->save();
parent::submitForm($form, $form_state);
}
}
Classes
Name![]() |
Description |
---|---|
SocialCommentUploadSettingsForm | Class SocialCommentUploadSettingsForm. |