public function DatabaseAggregatorSensorPluginBase::buildConfigurationForm in Monitoring 8
Form constructor.
Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.
Parameters
array $form: An associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Return value
array The form structure.
Overrides SensorPluginBase::buildConfigurationForm
2 calls to DatabaseAggregatorSensorPluginBase::buildConfigurationForm()
- ContentEntityAggregatorSensorPlugin::buildConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ ContentEntityAggregatorSensorPlugin.php - Adds UI for variables entity_type, conditions and verbose_fields.
- DatabaseAggregatorSensorPlugin::buildConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php - Adds UI for variables table, conditions and keys.
2 methods override DatabaseAggregatorSensorPluginBase::buildConfigurationForm()
- ContentEntityAggregatorSensorPlugin::buildConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ ContentEntityAggregatorSensorPlugin.php - Adds UI for variables entity_type, conditions and verbose_fields.
- DatabaseAggregatorSensorPlugin::buildConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php - Adds UI for variables table, conditions and keys.
File
- src/
SensorPlugin/ DatabaseAggregatorSensorPluginBase.php, line 76 - Contains \Drupal\monitoring\SensorPlugin\DatabaseAggregatorSensorPluginBase.
Class
- DatabaseAggregatorSensorPluginBase
- Base class for database aggregator sensors.
Namespace
Drupal\monitoring\SensorPluginCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['aggregation'] = array(
'#type' => 'fieldset',
'#title' => 'Time Aggregation',
// Give the aggregation settings a high weight, so that they show up
// after other configuration by default.
'#weight' => 50,
);
$form['aggregation']['time_interval_field'] = array(
'#type' => 'textfield',
'#title' => t('Timestamp field'),
'#default_value' => $this->sensorConfig
->getSetting('time_interval_field'),
'#access' => $this->configurableTimestampField,
);
$form['aggregation']['time_interval_value'] = array(
'#type' => 'select',
'#title' => t('Interval'),
'#options' => $this
->getTimeIntervalOptions(),
'#description' => t('Select the time interval for which the results will be aggregated.'),
'#default_value' => $this
->getTimeIntervalValue(),
);
// Always show the interval value if a timestamp field is forced, otherwise
// add states so it is only visible if something is entered.
if ($this->configurableTimestampField) {
$form['aggregation']['time_interval_value']['#states'] = array(
'invisible' => array(
':input[name="settings[aggregation][time_interval_field]"]' => array(
'value' => "",
),
),
);
}
return $form;
}