class BreadcrumbManagerConfigForm in Breadcrumb Manager 8
Class BreadcrumbManagerConfigForm.
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\breadcrumb_manager\Form\BreadcrumbManagerConfigForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of BreadcrumbManagerConfigForm
1 string reference to 'BreadcrumbManagerConfigForm'
File
- src/
Form/ BreadcrumbManagerConfigForm.php, line 14
Namespace
Drupal\breadcrumb_manager\FormView source
class BreadcrumbManagerConfigForm extends ConfigFormBase {
/**
* The Breadcrumb Title Resolver Plugin Manager.
*
* @var \Drupal\breadcrumb_manager\Plugin\BreadcrumbTitleResolverManager
*/
protected $titleResolverManager;
/**
* {@inheritdoc}
*/
public function __construct(ConfigFactoryInterface $config_factory, BreadcrumbTitleResolverManager $title_resolver_manager) {
parent::__construct($config_factory);
$this->titleResolverManager = $title_resolver_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('plugin.manager.breadcrumb_title_resolver'));
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'breadcrumb_manager.config',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'breadcrumb_manager_config_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('breadcrumb_manager.config');
$form['excluded_paths'] = [
'#type' => 'textarea',
'#title' => $this
->t('Excluded paths'),
'#default_value' => $config
->get('excluded_paths') ?: 'search/*',
'#description' => $this
->t('Enter a list of path that will not be affected by Breadcrumb Manager. You can use "*" as wildcard.'),
];
$form['show_front'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show on front page'),
'#default_value' => $config
->get('show_front'),
'#description' => $this
->t('If checked, the breadcrumb will be shown even on front page.'),
];
$form['show_home'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show "Home" breadcrumb link'),
'#default_value' => $config
->get('show_home'),
'#description' => $this
->t('Uncheck this option in order to omit Home link from breadcrumb. If you cannot see it even with this option, please check your frontend theme settings.'),
];
$form['home'] = [
'#type' => 'textfield',
'#title' => $this
->t('Override "Home" label'),
'#default_value' => $config
->get('home'),
'#attributes' => [
'placeholder' => 'Home',
],
'#states' => [
'visible' => [
':input[name="show_home"]' => [
'checked' => TRUE,
],
],
],
'#description' => $this
->t('Enter text that will override default "Home" label link. Leave it empty to use "Home".'),
];
$form['show_current'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show current page title at end'),
'#default_value' => $config
->get('show_current'),
'#description' => $this
->t('Uncheck this option in order to omit current page link from breadcrumb. If you cannot see it even with this option, please check your frontend theme settings.'),
];
$form['show_current_as_link'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Display last segment title as link'),
'#default_value' => $config
->get('show_current_as_link'),
'#description' => $this
->t('Check this option to display last item as a link. Otherwise it will be shown as plain text. If you cannot see it even with this option, please check your frontend theme settings.'),
];
$form['show_fake_segments'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Include fake segments'),
'#default_value' => $config
->get('show_fake_segments'),
'#description' => $this
->t('Include segments without route inside the breadcrumb.'),
];
$form['resolvers'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Title resolvers'),
];
$form['resolvers']['title_resolvers'] = [
'#type' => 'table',
'#header' => [
$this
->t('Name'),
$this
->t('Description'),
$this
->t('Enabled'),
$this
->t('Weight'),
],
'#tabledrag' => [
[
'action' => 'order',
'relationship' => 'sibling',
'group' => 'table-sort-weight',
],
],
];
$definitions = $this->titleResolverManager
->getDefinitions();
foreach ($definitions as $definition) {
$form['resolvers']['title_resolvers'][$definition['id']] = [
'#attributes' => [
'class' => 'draggable',
],
'#weight' => $definition['weight'],
'name' => [
'#markup' => $definition['label'],
],
'description' => [
'#markup' => $definition['description'],
],
'enabled' => [
'#title' => $this
->t('Enabled'),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#default_value' => $definition['enabled'],
],
'weight' => [
'#type' => 'weight',
'#title' => $this
->t('Weight for @title', [
'@title' => $definition['weight'],
]),
'#title_display' => 'invisible',
'#default_value' => $definition['weight'],
'#attributes' => [
'class' => [
'table-sort-weight',
],
],
],
];
}
$form['actions'] = [
'#type' => 'actions',
'submit' => [
'#type' => 'submit',
'#value' => $this
->t('Save settings'),
],
];
return $form;
}
/**
* {@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('breadcrumb_manager.config')
->set('excluded_paths', trim($form_state
->getValue('excluded_paths')))
->set('show_front', $form_state
->getValue('show_front'))
->set('show_home', $form_state
->getValue('show_home'))
->set('home', $form_state
->getValue('home'))
->set('show_current', $form_state
->getValue('show_current'))
->set('show_current_as_link', $form_state
->getValue('show_current_as_link'))
->set('show_fake_segments', $form_state
->getValue('show_fake_segments'))
->set('title_resolvers', $form_state
->getValue('title_resolvers'))
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BreadcrumbManagerConfigForm:: |
protected | property | The Breadcrumb Title Resolver Plugin Manager. | |
BreadcrumbManagerConfigForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
BreadcrumbManagerConfigForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
BreadcrumbManagerConfigForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
BreadcrumbManagerConfigForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
BreadcrumbManagerConfigForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
BreadcrumbManagerConfigForm:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
BreadcrumbManagerConfigForm:: |
public | function |
Constructs a \Drupal\system\ConfigFormBase object. Overrides ConfigFormBase:: |
|
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. | |
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. |