class ClaroExtrasSettingsForm in Claro Extras 1.0.x
Class ClaroExtrasSettingsForm.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\claro_extras\Form\ClaroExtrasSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of ClaroExtrasSettingsForm
1 string reference to 'ClaroExtrasSettingsForm'
File
- src/
Form/ ClaroExtrasSettingsForm.php, line 12
Namespace
Drupal\claro_extras\FormView source
class ClaroExtrasSettingsForm extends ConfigFormBase {
/**
* Drupal\Core\Entity\EntityTypeManagerInterface definition.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->entityTypeManager = $container
->get('entity_type.manager');
return $instance;
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'claro_extras.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'claro_extras_settings_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('claro_extras.settings');
$form['claro_extras_settings'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Claro extras settings'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
];
$form['claro_extras_settings']['tabs'] = [
'#type' => 'vertical_tabs',
'#default_tab' => 'basic_tab',
];
$form['claro_extras_settings']['basic_tab']['basic_settings'] = [
'#type' => 'details',
'#title' => $this
->t('Display settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'tabs',
];
$form['claro_extras_settings']['basic_tab']['basic_settings']['node_form_meta'] = [
'#type' => 'item',
'#markup' => '<div class="theme-settings-title">' . $this
->t("Node form meta block position") . '</div>',
];
$node_form_meta_default_value = $config
->get('node_form_meta') ?? NULL;
$form['claro_extras_settings']['basic_tab']['basic_settings']['node_form_meta'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Display block meta as vertical tabs'),
'#description' => $this
->t('Use the checkbox to display the node meta block as vertical tabs and under the main node form.'),
'#default_value' => $node_form_meta_default_value,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
$form['claro_extras_settings']['basic_tab']['basic_settings']['node_breadcrumbs'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Node Edit Breadcrumb'),
'#description' => $this
->t("Enable this if breadcrumbs show an erroneous 'node' breadcrumb link when editing a node."),
'#default_value' => $config
->get('node_breadcrumbs'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
$form['claro_extras_settings']['basic_tab']['basic_settings']['enhance_paragraph_titles'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enhance Paragraph titles'),
'#description' => $this
->t('Improved Paragraph titles display.'),
'#default_value' => $config
->get('enhance_paragraph_titles'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
$node_type = $this->entityTypeManager
->getStorage('node_type');
$options = array_map(function ($node_type) {
return $node_type
->label();
}, $node_type
->loadMultiple());
$default_value = $config
->get('node_form_meta_types') ?? [];
$form['claro_extras_settings']['basic_tab']['basic_settings']['node_form_meta_types'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Select the content types'),
'#description' => $this
->t('Select the content type on which display the node meta block as vertical tabs and under the main node form.'),
'#default_value' => $default_value ? array_filter($default_value) : [],
'#options' => $options,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#states' => [
'visible' => [
':input[name="node_form_meta"]' => [
'checked' => TRUE,
],
],
],
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$values = $form_state
->getValues();
$claro_extras_config = $this
->config('claro_extras.settings');
theme_settings_convert_to_config($values, $claro_extras_config)
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClaroExtrasSettingsForm:: |
protected | property | Drupal\Core\Entity\EntityTypeManagerInterface definition. | |
ClaroExtrasSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
ClaroExtrasSettingsForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
ClaroExtrasSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
ClaroExtrasSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
ClaroExtrasSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 16 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
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. |