You are here

public function FilesExtractor::getPropertyDefinitions in Search API attachments 8

Same name and namespace in other branches
  1. 9.0.x src/Plugin/search_api/processor/FilesExtractor.php \Drupal\search_api_attachments\Plugin\search_api\processor\FilesExtractor::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/FilesExtractor.php, line 160

Class

FilesExtractor
Provides file fields processor.

Namespace

Drupal\search_api_attachments\Plugin\search_api\processor

Code

public function getPropertyDefinitions(DatasourceInterface $datasource = NULL) {
  $properties = [];
  if (!$datasource) {

    // Add properties for all index available file fields and for file entity.
    foreach ($this
      ->getFileFieldsAndFileEntityItems() as $field_name => $label) {
      $definition = [
        'label' => $this
          ->t('Search api attachments: @label', [
          '@label' => $label,
        ]),
        'description' => $this
          ->t('Search api attachments: @label', [
          '@label' => $label,
        ]),
        'type' => 'string',
        'processor_id' => $this
          ->getPluginId(),
      ];
      $properties[static::SAA_PREFIX . $field_name] = new ProcessorProperty($definition);
    }
  }
  return $properties;
}