Container::getAlternatives

protected Container::getAlternatives($search_key, array $keys)

Provides alternatives for a given array and key.

Parameters

string $search_key: The search key to get alternatives for.

array $keys: The search space to search for alternatives in.

Return value

string[] An array of strings with suitable alternatives.

File

core/lib/Drupal/Component/DependencyInjection/Container.php, line 551

Class

Container
Provides a container optimized for Drupal's needs.

Namespace

Drupal\Component\DependencyInjection

Code

protected function getAlternatives($search_key, array $keys) {
  $alternatives = array();
  foreach ($keys as $key) {
    $lev = levenshtein($search_key, $key);
    if ($lev <= strlen($search_key) / 3 || strpos($key, $search_key) !== FALSE) {
      $alternatives[] = $key;
    }
  }

  return $alternatives;
}
doc_Drupal
2016-10-29 08:56:37
Comments
Leave a Comment

Please login to continue.