You are here

public static function SuggestionHelper::srcBits in Autocomplete Search Suggestions 3.0.x

Same name and namespace in other branches
  1. 8.2 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::srcBits()
  2. 8 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::srcBits()

Build an array of defalut options from bitmaps.

Parameters

int $src: The ngrams source bitmap.

Return value

array An array of default option.

1 call to SuggestionHelper::srcBits()
SuggestionEditForm::buildForm in src/Form/SuggestionEditForm.php
The suggestion edit form.

File

src/SuggestionHelper.php, line 270

Class

SuggestionHelper
Provides helper methods for suggestions.

Namespace

Drupal\suggestion

Code

public static function srcBits($src = 0) {
  $bits = [];
  if (intval($src) <= 0) {
    return [
      0,
    ];
  }
  foreach (array_keys(SuggestionStorage::getSrcOptions()) as $bit) {
    if ($bit & $src) {
      $bits[] = $bit;
    }
  }
  return $bits;
}