class TagcloudsAdminPage in TagCloud 8
Same name and namespace in other branches
- 2.0.x src/Form/TagcloudsAdminPage.php \Drupal\tagclouds\Form\TagcloudsAdminPage
- 1.0.x src/Form/TagcloudsAdminPage.php \Drupal\tagclouds\Form\TagcloudsAdminPage
Configure site information settings for this site.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\tagclouds\Form\TagcloudsAdminPage
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of TagcloudsAdminPage
1 string reference to 'TagcloudsAdminPage'
File
- src/
Form/ TagcloudsAdminPage.php, line 14
Namespace
Drupal\tagclouds\FormView source
class TagcloudsAdminPage extends ConfigFormBase {
/**
* The language manager.
*
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
*/
protected $languageManager;
/**
* Constructs a \Drupal\system\ConfigFormBase object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
*/
public function __construct(ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager) {
parent::__construct($config_factory);
$this->languageManager = $language_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('language_manager'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'tagclouds_settings';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('tagclouds.settings');
$options = [
'title,asc' => $this
->t('by title, ascending'),
'title,desc' => $this
->t('by title, descending'),
'count,asc' => $this
->t('by count, ascending'),
'count,desc' => $this
->t('by count, descending'),
'random,none' => $this
->t('random'),
];
$sort_order = $config
->get('sort_order');
$form['sort_order'] = [
'#type' => 'radios',
'#title' => $this
->t('Tagclouds sort order'),
'#options' => $options,
'#default_value' => !empty($sort_order) ? $sort_order : 'title,asc',
'#description' => $this
->t('Determines the sort order of the tags on the freetagging page.'),
];
$options_display = [
'style' => $this
->t('Display Tags with Style'),
'count' => $this
->t('Display Tags with Count'),
];
$display_type = $config
->get('display_type');
$form['display_type'] = [
'#type' => 'radios',
'#title' => $this
->t('Tagclouds Display Type'),
'#options' => $options_display,
'#default_value' => !empty($display_type) ? $display_type : 'style',
'#description' => $this
->t('Determines the style of the page.'),
];
$form['display_node_link'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Link term to node when only one content is tagged'),
'#default_value' => $config
->get('display_node_link'),
'#description' => $this
->t('When there is only one content tagged with a certain term, link that term to this node instead of the term list page.'),
];
$page_amount = $config
->get('page_amount');
$form['page_amount'] = [
'#type' => 'textfield',
'#size' => 5,
'#title' => $this
->t('Amount of tags on the pages'),
'#default_value' => is_numeric($page_amount) ? $page_amount : 60,
'#description' => $this
->t("The amount of tags that will show up in a cloud on the\n pages. Enter '0' to display all tags. Amount of tags in blocks must be\n configured in the block settings of the various cloud blocks."),
];
$levels = $config
->get('levels');
$form['levels'] = [
'#type' => 'textfield',
'#size' => 5,
'#title' => $this
->t('Number of levels'),
'#default_value' => is_numeric($levels) ? $levels : 6,
'#description' => $this
->t('The number of levels between the least popular
tags and the most popular ones. Different levels will be assigned a different
class to be themed in tagclouds.css'),
];
$lang = $this->languageManager
->getLanguages();
if (count($lang) > 1) {
$form['language_separation'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Separation of Tags per language'),
'#default_value' => $config
->get('language_separation'),
'#description' => $this
->t('If you have more than one language installed this setting would allow you to separate the tags for each language.'),
];
}
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('tagclouds.settings')
->set('sort_order', $form_state
->getValue('sort_order'))
->set('display_type', $form_state
->getValue('display_type'))
->set('display_node_link', $form_state
->getValue('display_node_link'))
->set('page_amount', $form_state
->getValue('page_amount'))
->set('levels', $form_state
->getValue('levels'));
if ($form_state
->hasValue('language_separation')) {
$this
->config('tagclouds.settings')
->set('language_separation', $form_state
->getValue('language_separation'));
}
$this
->config('tagclouds.settings')
->save();
parent::submitForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
function getEditableConfigNames() {
return [
'tagclouds.settings',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
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. Overrides UrlGeneratorTrait:: |
|
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:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
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. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
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. | 1 |
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. | |
TagcloudsAdminPage:: |
protected | property | The language manager. | |
TagcloudsAdminPage:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
TagcloudsAdminPage:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
TagcloudsAdminPage:: |
function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
||
TagcloudsAdminPage:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
TagcloudsAdminPage:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
TagcloudsAdminPage:: |
public | function |
Constructs a \Drupal\system\ConfigFormBase object. Overrides ConfigFormBase:: |
|
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |