class ErrorReporting in Production check & Production monitor 8
User register settings check
Plugin annotation
@ProdCheck(
id = "error_reporting",
title = @Translation("Error reporting"),
category = "settings",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\prod_check\Plugin\ProdCheck\ProdCheckBase implements ConfigurableInterface, ContainerFactoryPluginInterface, PluginFormInterface, ProdCheckInterface
- class \Drupal\prod_check\Plugin\ProdCheck\Settings\ErrorReporting
- class \Drupal\prod_check\Plugin\ProdCheck\ProdCheckBase implements ConfigurableInterface, ContainerFactoryPluginInterface, PluginFormInterface, ProdCheckInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ErrorReporting
File
- src/
Plugin/ ProdCheck/ Settings/ ErrorReporting.php, line 17
Namespace
Drupal\prod_check\Plugin\ProdCheck\SettingsView source
class ErrorReporting extends ProdCheckBase {
/**
* The currently selected option
*/
protected $current;
/**
* All the possible options
*/
protected $options;
/**
* {@inheritdoc}
*/
public function init() {
$this->current = $this->configFactory
->get('system.logging')
->get('error_level');
$this->options = [
ERROR_REPORTING_HIDE => $this
->t('Display no errors'),
ERROR_REPORTING_DISPLAY_SOME => $this
->t('Display errors and warnings'),
ERROR_REPORTING_DISPLAY_ALL => $this
->t('Display all messages'),
ERROR_REPORTING_DISPLAY_VERBOSE => $this
->t('Display all messages, plus backtrace information'),
];
}
/**
* {@inheritdoc}
*/
public function state() {
$options = $this->configuration['options'];
return !empty($options[$this->current]);
}
/**
* {@inheritdoc}
*/
public function successMessages() {
return [
'value' => $this->options[$this->current],
'description' => $this
->generateDescription($this
->title(), 'system.logging_settings'),
];
}
/**
* {@inheritdoc}
*/
public function failMessages() {
$link_array = $this
->generateLinkArray($this
->title(), 'system.logging_settings');
return [
'value' => $this->options[$this->current],
'description' => $this
->t('Your %link settings are set to "@current". Are you sure this is what you want and did not mean to use @options?', [
'%link' => implode($link_array),
'@current' => $this->options[$this->current],
'@options' => '"' . implode('" ' . t('or') . ' "', $this
->getSelectedOptions()) . '"',
]),
];
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$configuration = parent::defaultConfiguration();
$configuration['options'] = [
ERROR_REPORTING_HIDE => ERROR_REPORTING_HIDE,
ERROR_REPORTING_DISPLAY_SOME => 0,
ERROR_REPORTING_DISPLAY_ALL => 0,
ERROR_REPORTING_DISPLAY_VERBOSE => 0,
];
return $configuration;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['options'] = [
'#type' => 'checkboxes',
'#title' => t('Valid error reporting options'),
'#default_value' => $this->configuration['options'],
'#options' => $this->options,
'#required' => TRUE,
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$this->configuration['options'] = $form_state
->getValue('options');
}
/**
* Fetches all the selected options.
*/
protected function getSelectedOptions() {
$selected_options = [];
foreach ($this->configuration['options'] as $option) {
if (!empty($option)) {
$selected_options[] = $this->options[$option];
}
}
return $selected_options;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 | |
ErrorReporting:: |
protected | property | The currently selected option | |
ErrorReporting:: |
protected | property | All the possible options | |
ErrorReporting:: |
public | function |
Form constructor. Overrides ProdCheckBase:: |
|
ErrorReporting:: |
public | function |
Gets default configuration for this plugin. Overrides ProdCheckBase:: |
|
ErrorReporting:: |
public | function |
Returns the fail messages for the check Overrides ProdCheckInterface:: |
|
ErrorReporting:: |
protected | function | Fetches all the selected options. | |
ErrorReporting:: |
public | function |
Initializes the check plugin. Overrides ProdCheckBase:: |
|
ErrorReporting:: |
public | function |
Calculates the state for the check. Overrides ProdCheckInterface:: |
|
ErrorReporting:: |
public | function |
Form submission handler. Overrides ProdCheckBase:: |
|
ErrorReporting:: |
public | function |
Returns the success messages for the check. Overrides ProdCheckInterface:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ProdCheckBase:: |
protected | property | The config factory | |
ProdCheckBase:: |
protected | property | The date formatter service | |
ProdCheckBase:: |
protected | property | The redirect destination service. | |
ProdCheckBase:: |
protected | property | The link generator service. | |
ProdCheckBase:: |
protected | property | The module handler service | 1 |
ProdCheckBase:: |
protected | property | The prod check processor plugin manager. | |
ProdCheckBase:: |
public | function | ||
ProdCheckBase:: |
public | function |
Returns the title of the check Overrides ProdCheckInterface:: |
|
ProdCheckBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
ProdCheckBase:: |
public | function |
Returns the extra data of the check. Overrides ProdCheckInterface:: |
1 |
ProdCheckBase:: |
protected | function | Helper function to generate generic 'settings OK' description. | |
ProdCheckBase:: |
protected | function | Helper function to generate link array to pass to the t() function | |
ProdCheckBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
ProdCheckBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
ProdCheckBase:: |
public | function | Sets the processor | |
ProdCheckBase:: |
public | function |
Defines the severity of the check. Overrides ProdCheckInterface:: |
2 |
ProdCheckBase:: |
public | function |
Returns the title of the plugin. Overrides ProdCheckInterface:: |
|
ProdCheckBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
ProdCheckBase:: |
public | function |
Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
1 |
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. |