You are here

public function SearchApiGlossaryAZProcessor::getPropertyDefinitions in Search API AZ Glossary 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/search_api/processor/SearchApiGlossaryAZProcessor.php \Drupal\search_api_glossary\Plugin\search_api\processor\SearchApiGlossaryAZProcessor::getPropertyDefinitions()

Retrieves the properties this processor defines for the given datasource.

Property names have to start with a letter or an underscore, followed by any number of letters, numbers and underscores. To avoid collisions, it is also recommended to prefix the property name with the identifier of the module defining the processor.

Parameters

\Drupal\search_api\Datasource\DatasourceInterface|null $datasource: (optional) The datasource this set of properties belongs to. If NULL, the datasource-independent properties should be added (or modified).

Return value

\Drupal\search_api\Processor\ProcessorPropertyInterface[] An array of property definitions for that datasource, keyed by property names.

Overrides ProcessorPluginBase::getPropertyDefinitions

File

src/Plugin/search_api/processor/SearchApiGlossaryAZProcessor.php, line 30

Class

SearchApiGlossaryAZProcessor
Adds the item's AZ to the indexed data.

Namespace

Drupal\search_api_glossary\Plugin\search_api\processor

Code

public function getPropertyDefinitions(DatasourceInterface $datasource = NULL) {
  $properties = [];
  if (!$datasource) {
    $config = \Drupal::config('search_api_glossary.settings');
    $search_api_glossary_settings = $config
      ->get();
    if (!empty($search_api_glossary_settings)) {

      // Loop through the saved config from.
      // Search API field settings form.
      foreach ($search_api_glossary_settings as $value) {

        // Create the fields.
        if ($value['enabled'] == 1) {
          $definition = [
            'label' => $this
              ->t($value['glossary_field_name']),
            'description' => $this
              ->t($value['glossary_field_desc']),
            'type' => 'string',
            'processor_id' => $this
              ->getPluginId(),
          ];
          $properties[$value['glossary_field_id']] = new ProcessorProperty($definition);
        }
      }
    }
  }
  return $properties;
}