class FlagListsSettingForm in Flag Lists 4.0.x
Class FlaggingCollectionSettingsForm.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\flag_lists\Form\FlagListsSettingForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of FlagListsSettingForm
1 string reference to 'FlagListsSettingForm'
File
- src/
Form/ FlagListsSettingForm.php, line 19
Namespace
Drupal\flag_lists\FormView source
class FlagListsSettingForm extends ConfigFormBase {
/**
* The Cache Tags Invalidator.
*
* @var \Drupal\Core\Cache\CacheTagsInvalidator
* The cache tags handler.
*/
protected $cacheTagsInvalidator;
/**
* The Entity Type Manager.
*
* @var \Drupal\Core\EntityTypeManager
* The entity type manager.
*/
protected $entityTypeManager;
/**
* The Entity Display Repository.
*
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
* The entity display repository.
*/
protected $entityDisplayRepository;
/**
* {@inheritdoc}
*/
public function __construct(ConfigFactoryInterface $config_factory, CacheTagsInvalidator $cache_tags_invalidator, EntityTypeManager $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository) {
parent::__construct($config_factory);
$this->cacheTagsInvalidator = $cache_tags_invalidator;
$this->entityTypeManager = $entity_type_manager;
$this->entityDisplayRepository = $entity_display_repository;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('cache_tags.invalidator'), $container
->get('entity_type.manager'), $container
->get('entity_display.repository'));
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'flag_lists.settings',
];
}
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'flag_lists_settings_form';
}
/**
* Form submission handler.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('flag_lists.settings')
->set('hide_collections', $form_state
->getValue('hide_collections'))
->save();
$this
->config('flag_lists.settings')
->set('hide_collections_in_displays', $form_state
->getValue('hide_collections_in_displays'))
->save();
$this
->config('flag_lists.settings')
->set('hide_templates_in_displays', $form_state
->getValue('hide_templates_in_displays'))
->save();
$clearCacheLink = Link::createFromRoute('cache', 'system.performance_settings')
->toString();
$this
->messenger()
->addStatus($this
->t('If needed, please clear the @link!', [
'@link' => $clearCacheLink,
]));
// Only invalidating using the generic cache tag.
$this->cacheTagsInvalidator
->invalidateTags([
'config:entity_view_display_list',
]);
}
/**
* Defines the settings form for Flagging collection entities.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* Form definition array.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('flag_lists.settings');
$form['flag_settings'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Overview Settings'),
];
$flagOverviewLink = Link::createFromRoute('Flag Overview', 'entity.flag.collection')
->toString();
$form['flag_settings']['hide_collections'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Hide Flagging Collections in the @link.', [
'@link' => $flagOverviewLink,
]),
'#default_value' => $config
->get('hide_collections'),
'#description' => $this
->t('Do you want to hide the Flagging Collections in the @link?', [
'@link' => $flagOverviewLink,
]),
];
$flagCollectionsInDisplayLink = Link::createFromRoute('Content Types Manage Display Forms', 'entity.node_type.collection')
->toString();
$form['content_types'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Content Types Settings'),
];
$form['content_types']['hide_collections_in_displays'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Hide Flagging Collections in the @link as well as for other entities.', [
'@link' => $flagCollectionsInDisplayLink,
]),
'#default_value' => $config
->get('hide_collections_in_displays'),
'#description' => $this
->t('Do you want to hide the Flagging Collections in the @link as well as for other entities?', [
'@link' => $flagCollectionsInDisplayLink,
]),
];
$form['content_types']['hide_templates_in_displays'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Hide Flagging Templates in the @link as well as for other entities.', [
'@link' => $flagCollectionsInDisplayLink,
]),
'#default_value' => $config
->get('hide_templates_in_displays'),
'#description' => $this
->t('Do you want to hide the Flagging Templates in the @link as well as for other entities?', [
'@link' => $flagCollectionsInDisplayLink,
]),
];
return parent::buildForm($form, $form_state);
}
}
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 | |
FlagListsSettingForm:: |
protected | property | The Cache Tags Invalidator. | |
FlagListsSettingForm:: |
protected | property | The Entity Display Repository. | |
FlagListsSettingForm:: |
protected | property | The Entity Type Manager. | |
FlagListsSettingForm:: |
public | function |
Defines the settings form for Flagging collection entities. Overrides ConfigFormBase:: |
|
FlagListsSettingForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
FlagListsSettingForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
FlagListsSettingForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
FlagListsSettingForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
FlagListsSettingForm:: |
public | function |
Constructs a \Drupal\system\ConfigFormBase object. Overrides ConfigFormBase:: |
|
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. | |
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. |