class PaceAdminSettingsForm in PACE - Page load progress bar 8
Same name and namespace in other branches
- 2.0.x src/Form/PaceAdminSettingsForm.php \Drupal\pace\Form\PaceAdminSettingsForm
Implements settings form.
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\pace\Form\PaceAdminSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of PaceAdminSettingsForm
1 string reference to 'PaceAdminSettingsForm'
File
- src/
Form/ PaceAdminSettingsForm.php, line 16 - Contains \Drupal\pace\Form\PaceAdminSettingsForm.
Namespace
Drupal\pace\FormView source
class PaceAdminSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'pace_admin_settings_form';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'pace.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('pace.settings');
$form['pace_theme'] = array(
'#title' => t('Select the theme that PACE should use'),
'#description' => t('Pace comes with a lot of themes for the progress loader. Please select the one that you prefer. You can see them all here: http://github.hubspot.com/pace/docs/welcome/'),
'#type' => 'radios',
'#options' => array(
'minimal' => 'minimal',
'barber-shop' => 'barber',
'big-counter' => 'big counter',
'bounce' => 'bounce',
'center-atom' => 'center atom',
'center-circle' => 'center circle',
'center-radar' => 'center radar',
'center-simple' => 'center simple',
'corner-indicator' => 'corner indicator',
'fill-left' => 'fill left',
'flash' => 'flash',
'flat-top' => 'flat top',
'loading-bar' => 'loading bar',
'mac-osx' => 'mac osx',
'material' => 'material',
),
'#default_value' => $config
->get('pace_theme') ?: 'minimal',
);
$form['pace_color'] = [
'#title' => t('Select the color of the theme'),
'#type' => 'radios',
'#options' => [
'black' => 'black',
'blue' => 'blue',
'green' => 'green',
'orange' => 'orange',
'pink' => 'pink',
'purple' => 'purple',
'red' => 'red',
'silver' => 'silver',
'white' => 'white',
'yellow' => 'yellow',
],
'#default_value' => $config
->get('pace_color') ?: 'blue',
];
$form['pace_load_on_admin_enabled'] = array(
'#title' => t('Load in administration pages.'),
'#description' => t('PACE is disabled by default on administration pages. Check to enable'),
'#type' => 'checkbox',
'#default_value' => $config
->get('pace_load_on_admin_enabled') ?: FALSE,
);
$form['color_notes'] = [
'#type' => 'markup',
'#markup' => t('<legend><strong>PACE Styling</strong></legend>To style PACE add a style tag like:<br><code>.pace .pace-progress { background: red; }</code><br> in your html.html.twig file inside the head tag.<br>It doesn\'t work for all PACE themes.<br>Setting the color from the UI is disabled because of <a href="https://drupal.stackexchange.com/questions/212376/attach-dynamic-inline-css-to-head" target="_blank">this</a>.'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('pace.settings')
->set('pace_theme', $form_state
->getValue('pace_theme'))
->set('pace_color', $form_state
->getValue('pace_color'))
->set('pace_load_on_admin_enabled', $form_state
->getValue('pace_load_on_admin_enabled'))
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
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. | |
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. | |
PaceAdminSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
PaceAdminSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
PaceAdminSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
PaceAdminSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
PaceAdminSettingsForm:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
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. | |
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. |