You are here

class FeedsLdapQueryFetcher in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_feeds/FeedsLdapQueryFetcher.inc \FeedsLdapQueryFetcher
  2. 7 ldap_feeds/FeedsLdapQueryFetcher.inc \FeedsLdapQueryFetcher

Fetches data via LDAP Query.

Hierarchy

Expanded class hierarchy of FeedsLdapQueryFetcher

3 string references to 'FeedsLdapQueryFetcher'
ldap_feeds_feeds_plugins in ldap_feeds/ldap_feeds.module
Implements hook_feeds_plugins().
ldap_feeds_form_feeds_ui_mapping_form_alter in ldap_feeds/ldap_feeds.module
Show some sample ldap user data to help with mapping interface.
ldap_feeds_query_legend in ldap_feeds/ldap_feeds.module
Add additional data to mapping form for ldap query fetcher.

File

ldap_feeds/FeedsLdapQueryFetcher.inc, line 51
FeedsLdapQueryFetcher.

View source
class FeedsLdapQueryFetcher extends FeedsFetcher {

  /**
   * Implements FeedsFetcher::fetch().
   */
  public function fetch(FeedsSource $source) {
    $source_config = $source
      ->getConfigFor($this);
    $result = new FeedsLdapQueryFetcherResult($source_config);
    return $result;
  }

  /**
   * Override parent::configDefaults().
   */
  public function configDefaults() {
    return [
      'query_ids' => [],
    ];
  }

  /**
   * Override parent::configForm().
   */
  public function configForm(&$form_state) {
    $queries = ldap_query_get_queries(NULL, 'enabled');
    $query_options = [
      0 => '--- select one or more queries ---',
    ];
    foreach ($queries as $qid => $query) {
      $query_options[$qid] = $query->name;
    }
    $form = [];
    $form['query_ids'] = [
      '#type' => 'select',
      '#title' => t('LDAP Query'),
      '#multiple' => TRUE,
      '#size' => min(10, count($query_options)),
      '#required' => TRUE,
      '#default_value' => $this->config['query_ids'],
      '#description' => t('If more than one query is selected, results from all the queries will be returned.') . ' ' . t('Queries can be added and edited at !link', [
        '!link' => l(t('LDAP Query Admin'), LDAP_QUERY_INDEX_BASE_PATH),
      ]),
      '#options' => $query_options,
    ];
    return $form;
  }

  /**
   * Override parent::sourceForm().
   */
  public function sourceForm($source_config) {
    $tokens = [
      '!edit_link' => l(t('Edit Feed'), 'admin/structure/feeds/' . $this->id),
    ];
    $form_state = [];
    $form = $this
      ->configForm($form_state);
    $form['preamble'] = [
      '#type' => 'markup',
      '#markup' => t('This import is configured at !edit_link.', $tokens),
    ];
    return $form;
  }

  /**
   * Override parent::sourceFormValidate().
   */
  public function sourceFormValidate(&$values) {

    // Could execute query and see if it returns anything for validation.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsLdapQueryFetcher::configDefaults public function Override parent::configDefaults().
FeedsLdapQueryFetcher::configForm public function Override parent::configForm().
FeedsLdapQueryFetcher::fetch public function Implements FeedsFetcher::fetch().
FeedsLdapQueryFetcher::sourceForm public function Override parent::sourceForm().
FeedsLdapQueryFetcher::sourceFormValidate public function Override parent::sourceFormValidate().