You are here

public function Role::getPropertyDefinitions in Search API Sort Priority 8

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/Role.php, line 57

Class

Role
Adds customized sort priority by Role.

Namespace

Drupal\search_api_sort_priority\Plugin\search_api\processor

Code

public function getPropertyDefinitions(DatasourceInterface $datasource = NULL) {
  $properties = [];
  if (!$datasource) {
    $definition = [
      // TODO Come up with better label.
      'label' => $this
        ->t('Sort Priority by Role'),
      // TODO Come up with better description.
      'description' => $this
        ->t('Sort Priority by Role.'),
      'type' => 'integer',
      'processor_id' => $this
        ->getPluginId(),
      // This will be a hidden field,
      // not something a user can add/remove manually.
      'hidden' => TRUE,
    ];
    $properties[$this->targetFieldId] = new ProcessorProperty($definition);
  }
  return $properties;
}