public function SoulMate::getPropertyDefinitions in Search API 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
- tests/
search_api_test_extraction/ src/ Plugin/ search_api/ processor/ SoulMate.php, line 123
Class
- SoulMate
- Adds the user's soul mate node for indexing.
Namespace
Drupal\search_api_test_extraction\Plugin\search_api\processorCode
public function getPropertyDefinitions(DatasourceInterface $datasource = NULL) {
$properties = [];
if ($datasource && $datasource
->getEntityTypeId() && $datasource
->getEntityTypeId() !== 'user') {
$definition = [
'label' => $this
->t('Soul mate'),
'description' => $this
->t("The User with the same UID as the entity's ID"),
'type' => 'entity:user',
'processor_id' => $this
->getPluginId(),
];
$properties['soul_mate'] = new EntityProcessorProperty($definition);
$properties['soul_mate']
->setEntityTypeId('user');
}
return $properties;
}