You are here

function features_autocomplete_packages in Features 7.2

Same name and namespace in other branches
  1. 7 features.admin.inc \features_autocomplete_packages()

Page callback: Autocomplete field for features package.

Parameters

string $search_string: The char or string that user have written in autocomplete field, this is the string this function uses for filter.

See also

features_menu()

1 string reference to 'features_autocomplete_packages'
features_menu in ./features.module
Implements hook_menu().

File

./features.admin.inc, line 1846
Forms for Features admin screens.

Code

function features_autocomplete_packages($search_string) {
  $matched_packages = array();

  // Collect matching package names from existing features.
  foreach (features_get_features(NULL, TRUE) as $value) {

    // @todo More efficient: Collect all package names, then preg_grep() later.
    if (preg_match('/' . $search_string . '/i', $value->info['package'])) {
      $matched_packages[$value->info['package']] = $value->info['package'];
    }
  }

  // Remove duplicate package names.
  // @todo This is not necessary, the array keys already guarantee uniqueness.
  $matched_packages = array_unique($matched_packages);
  drupal_json_output($matched_packages);
}