class NewRelicRpmSettings in New Relic 8
Same name and namespace in other branches
- 2.x src/Form/NewRelicRpmSettings.php \Drupal\new_relic_rpm\Form\NewRelicRpmSettings
- 2.0.x src/Form/NewRelicRpmSettings.php \Drupal\new_relic_rpm\Form\NewRelicRpmSettings
Provides a settings form to configure the New Relic RPM module.
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\new_relic_rpm\Form\NewRelicRpmSettings
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of NewRelicRpmSettings
1 string reference to 'NewRelicRpmSettings'
File
- src/
Form/ NewRelicRpmSettings.php, line 12
Namespace
Drupal\new_relic_rpm\FormView source
class NewRelicRpmSettings extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'new_relic_rpm_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'new_relic_rpm.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = [];
$form['api_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('API Key'),
'#description' => $this
->t('Enter your New Relic API key if you wish to view reports and analysis within Drupal.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('api_key'),
];
$form['transactions'] = [
'#type' => 'details',
'#title' => $this
->t('Transactions'),
'#open' => TRUE,
];
$form['transactions']['track_drush'] = [
'#type' => 'select',
'#title' => $this
->t('Drush transactions'),
'#description' => $this
->t('How do you wish New Relic to track drush commands?'),
'#options' => [
'ignore' => $this
->t('Ignore completely'),
'bg' => $this
->t('Track as background tasks'),
'norm' => $this
->t('Track normally'),
],
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('track_drush'),
];
$form['transactions']['track_cron'] = [
'#type' => 'select',
'#title' => $this
->t('Cron transactions'),
'#description' => $this
->t('How do you wish New Relic to track cron tasks?'),
'#options' => [
'ignore' => $this
->t('Ignore completely'),
'bg' => $this
->t('Track as background tasks'),
'norm' => $this
->t('Track normally'),
],
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('track_cron'),
];
$roles = user_role_names();
$form['transactions']['ignore_roles'] = [
'#type' => 'select',
'#multiple' => TRUE,
'#title' => $this
->t('Ignore roles'),
'#description' => $this
->t('Select roles that you wish to be ignored on the New Relic dashboards. Any user with at least one of the selected roles will be ignored.'),
'#options' => $roles,
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('ignore_roles'),
];
$form['transactions']['ignore_urls'] = [
'#type' => 'textarea',
'#wysiwyg' => FALSE,
'#title' => $this
->t('Ignore URLs'),
'#description' => $this
->t('Enter URLs you wish New Relic to ignore. Enter one URL per line.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('ignore_urls'),
];
$form['transactions']['bg_urls'] = [
'#type' => 'textarea',
'#wysiwyg' => FALSE,
'#title' => $this
->t('Background URLs'),
'#description' => $this
->t('Enter URLs you wish to have tracked as background tasks. Enter one URL per line.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('bg_urls'),
];
$form['transactions']['exclusive_urls'] = [
'#type' => 'textarea',
'#wysiwyg' => FALSE,
'#title' => $this
->t('Exclusive URLs'),
'#description' => $this
->t('Enter URLs you wish to exclusively track. This is useful for debugging specific issues. **NOTE** Entering URLs here effectively marks all other URLs as ignored. Leave blank to disable.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('exclusive_urls'),
];
$form['error'] = [
'#type' => 'details',
'#title' => $this
->t('Error analytics'),
'#open' => TRUE,
];
$form['error']['watchdog_severities'] = [
'#type' => 'select',
'#multiple' => TRUE,
'#title' => $this
->t('Forward watchdog messages'),
'#description' => $this
->t('Select which watchdog severities should be forwarded to New Relic API as errors.'),
'#options' => RfcLogLevel::getLevels(),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('watchdog_severities'),
];
$form['error']['override_exception_handler'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Override exception handler'),
'#description' => $this
->t('Check to override default Drupal exception handler and to have exceptions passed to New Relic.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('override_exception_handler'),
];
$form['deployment'] = [
'#type' => 'details',
'#title' => $this
->t('Deployments'),
'#open' => TRUE,
];
$form['deployment']['module_deployment'] = [
'#type' => 'select',
'#title' => $this
->t('Track module activation as deployment'),
'#description' => $this
->t('Turning this on will create a "deployment" on the New Relic dashboard each time a module is installed or uninstalled. This will help you track before and after statistics.'),
'#options' => [
1 => $this
->t('Enable'),
0 => $this
->t('Disable'),
],
'#default_value' => (int) $this
->config('new_relic_rpm.settings')
->get('module_deployment'),
];
$form['deployment']['config_import'] = [
'#type' => 'select',
'#title' => $this
->t('Track configuration imports as deployment'),
'#description' => $this
->t('Turning this on will create a "deployment" on the New Relic dashboard each time a set of configuration is imported. This will help you track before and after statistics.'),
'#options' => [
1 => $this
->t('Enable'),
0 => $this
->t('Disable'),
],
'#default_value' => (int) $this
->config('new_relic_rpm.settings')
->get('config_import'),
];
$form['browser'] = [
'#type' => 'details',
'#title' => $this
->t('Browser'),
'#open' => TRUE,
];
$form['browser']['disable_autorum'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Disable AutoRUM'),
'#description' => $this
->t('Check to disable the automatic real user monitoring inserted by a New Relic transaction.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('disable_autorum'),
];
$form['insights'] = [
'#type' => 'details',
'#title' => $this
->t('Insights'),
'#open' => TRUE,
];
$form['insights']['views_log_slow'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Track slow views'),
'#description' => $this
->t('Check if you want to log slow views in New Relic as custom events.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('views_log_slow'),
];
$form['insights']['views_log_threshold'] = [
'#type' => 'number',
'#title' => $this
->t('Slow view threshold'),
'#field_suffix' => 'ms',
'#description' => $this
->t('The amount of time in milliseconds before a slow view event is logged in New Relic.'),
'#default_value' => $this
->config('new_relic_rpm.settings')
->get('views_log_threshold'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('new_relic_rpm.settings');
$variables = [
'api_key',
'track_drush',
'track_cron',
'ignore_roles',
'ignore_urls',
'bg_urls',
'exclusive_urls',
'watchdog_severities',
'override_exception_handler',
'module_deployment',
'config_import',
'views_log_slow',
'views_log_threshold',
'disable_autorum',
];
foreach ($variables as $variable) {
$config
->set($variable, $form_state
->getValue($variable));
}
$config
->save();
parent::submitForm($form, $form_state);
}
}
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. | |
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. | |
NewRelicRpmSettings:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
NewRelicRpmSettings:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
NewRelicRpmSettings:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
NewRelicRpmSettings:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
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. |