You are here

class SearchApiGlossaryAZHelper in Search API AZ Glossary 8

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

Search Api GlossaryAZ Helper class.

@package Drupal\search_api_glossary

Hierarchy

Expanded class hierarchy of SearchApiGlossaryAZHelper

1 file declares its use of SearchApiGlossaryAZHelper
SearchApiGlossaryAZProcessor.php in src/Plugin/search_api/processor/SearchApiGlossaryAZProcessor.php

File

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

Namespace

Drupal\search_api_glossary
View source
class SearchApiGlossaryAZHelper {

  /**
   * Getter callback for title_az_glossary property.
   */
  public function glossaryGetter($source_value, $glossary_az_grouping) {
    $first_letter = strtoupper(substr(trim($source_value), 0, 1));
    return self::glossaryGetterHelper($first_letter, array_values($glossary_az_grouping));
  }

  /**
   * Getter Helper for Alpha Numeric Keys.
   */
  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;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SearchApiGlossaryAZHelper::glossaryGetter public function Getter callback for title_az_glossary property.
SearchApiGlossaryAZHelper::glossaryGetterHelper public function Getter Helper for Alpha Numeric Keys.