You are here

public function SearchApiGlossaryAZHelper::glossaryGetterHelper in Search API AZ Glossary 8

Same name and namespace in other branches
  1. 8.2 src/SearchApiGlossaryAZHelper.php \Drupal\search_api_glossary\SearchApiGlossaryAZHelper::glossaryGetterHelper()

Getter Helper for Alpha Numeric Keys.

1 call to SearchApiGlossaryAZHelper::glossaryGetterHelper()
SearchApiGlossaryAZHelper::glossaryGetter in src/SearchApiGlossaryAZHelper.php
Getter callback for title_az_glossary property.

File

src/SearchApiGlossaryAZHelper.php, line 28
Contains Drupal\search_api_glossary\SearchApiGlossaryAZHelper.

Class

SearchApiGlossaryAZHelper
Search Api GlossaryAZ Helper class.

Namespace

Drupal\search_api_glossary

Code

public function glossaryGetterHelper($first_letter, $glossary_az_grouping) {

  // Is it Alpha?
  if (ctype_alpha($first_letter)) {

    // Do we have Alpha grouping?
    if (in_array('glossary_az_grouping_az', $glossary_az_grouping, TRUE)) {
      $first_letter = "A-Z";
    }
    return $first_letter;
  }
  elseif (ctype_digit($first_letter)) {

    // Do we have Numeric grouping?
    if (in_array('glossary_az_grouping_09', $glossary_az_grouping, TRUE)) {
      $first_letter = "0-9";
    }
    return $first_letter;
  }
  elseif (in_array('glossary_az_grouping_other', $glossary_az_grouping, TRUE)) {
    $first_letter = "#";
    return $first_letter;
  }
}