You are here

public function SensorCommerceTurnover::settingsForm in Monitoring 7

Adds the order statuses select element to the sensor settings form.

Overrides SensorDatabaseAggregator::settingsForm

File

lib/Drupal/monitoring/Sensor/Sensors/SensorCommerceTurnover.php, line 72
Contains \Drupal\monitoring\Sensor\Sensors\SensorCommerceTurnover.

Class

SensorCommerceTurnover
Monitors commerce order turnover stats.

Namespace

Drupal\monitoring\Sensor\Sensors

Code

public function settingsForm($form, &$form_state) {
  $form = parent::settingsForm($form, $form_state);
  $conditions = $this->info
    ->getSetting('conditions');
  $options = array();
  foreach (commerce_order_statuses() as $name => $info) {
    $options[$name] = $info['title'];
  }
  $form['conditions']['status']['value'] = array(
    '#type' => 'select',
    '#title' => t('"Paid" order statuses'),
    '#description' => t('Select order statuses in which the order is considered to be paid.'),
    '#options' => $options,
    '#multiple' => TRUE,
    '#default_value' => $conditions['status']['value'],
  );
  return $form;
}