You are here

public function EventHandler::configForm in Services Client 7.2

Configuration form.

Overrides ServicesClientPlugin::configForm

1 call to EventHandler::configForm()
EntitySaveHandler::configForm in include/event.inc
Configuration form.
1 method overrides EventHandler::configForm()
EntitySaveHandler::configForm in include/event.inc
Configuration form.

File

include/event.inc, line 217

Class

EventHandler
Event handler plugin.

Code

public function configForm(&$form, &$form_state) {

  // Show conditions
  $conditions = array();
  foreach ($this->config['condition'] as $uuid => $plugin) {
    try {
      $handler = $this
        ->getPluginInstance($plugin['type'], $plugin['config'], $uuid);
      $conditions[] = array(
        $handler
          ->getSummary(),
        implode(' | ', array(
          l(t('Edit'), $this
            ->getUrl('plugin/condition/' . $uuid . '/edit')),
          l(t('Remove'), $this
            ->getUrl('plugin/condition/' . $uuid . '/remove'), array(
            'query' => array(
              'token' => drupal_get_token($uuid),
            ),
          )),
        )),
      );
    } catch (Exception $e) {
      watchdog_exception('services_client', $e);
    }
  }
  $form['condition']['title'] = array(
    '#markup' => '<h2>' . t('Conditions') . '</h2>',
  );
  $form['condition']['table'] = array(
    '#theme' => 'table',
    '#header' => array(
      t('Name'),
      t('Actions'),
    ),
    '#rows' => $conditions,
    '#empty' => t('There are no conditions added'),
  );
  $form['condition']['add_condition'] = array(
    '#theme_wrappers' => array(
      'container',
    ),
    '#markup' => l('+ ' . t('Add condition'), $this
      ->getUrl('add_plugin/condition')),
  );
  $form['remote'] = array(
    '#type' => 'fieldset',
    '#title' => t('Remote configuration'),
    '#tree' => FALSE,
    '#weight' => 100,
  );
  $form['remote']['uuid_version'] = array(
    '#type' => 'select',
    '#title' => t('UUID version'),
    '#description' => t('UUID version on remote site.'),
    '#options' => array(
      'alpha1' => t('7.0 alpha-1'),
      'alpha3+' => t('7.0 alpha-3 and higher'),
    ),
    '#default_value' => $this->config['uuid_version'],
  );
  $form['remote']['uuid_resource'] = array(
    '#type' => 'textfield',
    '#title' => t('UUID resource'),
    '#description' => t('Name of the uuid resource that should be searched.'),
    '#default_value' => $this->config['uuid_resource'],
  );
  $form['remote']['resource'] = array(
    '#type' => 'textfield',
    '#title' => t('Remote resource name'),
    '#description' => t("Provide remote resource name i.e. 'node_raw'."),
    '#default_value' => $this->config['resource'],
  );
  $form['event'] = array(
    '#type' => 'fieldset',
    '#title' => t('Event configuration'),
    '#tree' => FALSE,
    '#weight' => 200,
  );
  $form['event']['auto_triggered'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically triggered'),
    '#description' => t('This event will be triggered automatically when event happens in Drupal. I.e. on node_save call.'),
    '#default_value' => $this->config['auto_triggered'],
  );
  $form['event']['queue'] = array(
    '#type' => 'checkbox',
    '#title' => t('Queue execution'),
    '#description' => t('Queue execution of this event in all cases.'),
    '#default_value' => isset($this->config['queue']) ? $this->config['queue'] : NULL,
    '#states' => array(
      'visible' => array(
        ':input[name="auto_triggered"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['event']['debug'] = array(
    '#type' => 'select',
    '#title' => t('Logging level'),
    '#description' => t('Select level of debugging information sent to log.'),
    '#options' => ServicesClientLogLevel::getLevels(),
    '#default_value' => $this->config['debug'],
  );
}