public function Index::getPropertyDefinitions in Search API 8
Retrieves the properties of one of this index's datasources.
Parameters
string|null $datasource_id: The ID of the datasource for which the properties should be retrieved. Or NULL to retrieve all datasource-independent properties.
Return value
\Drupal\Core\TypedData\DataDefinitionInterface[] The properties belonging to the given datasource that are available in this index, keyed by their property names (not the complete field IDs).
Throws
\Drupal\search_api\SearchApiException Thrown if the specified datasource isn't enabled for this index, or couldn't be loaded.
Overrides IndexInterface::getPropertyDefinitions
1 call to Index::getPropertyDefinitions()
- Index::preSave in src/
Entity/ Index.php - Acts on an entity before the presave hook is invoked.
File
- src/
Entity/ Index.php, line 832
Class
- Index
- Defines the search index configuration entity.
Namespace
Drupal\search_api\EntityCode
public function getPropertyDefinitions($datasource_id) {
if (!isset($this->properties[$datasource_id])) {
if (isset($datasource_id)) {
$datasource = $this
->getDatasource($datasource_id);
$properties = $datasource
->getPropertyDefinitions();
}
else {
$datasource = NULL;
$properties = [];
}
foreach ($this
->getProcessorsByStage(ProcessorInterface::STAGE_ADD_PROPERTIES) as $processor) {
$properties += $processor
->getPropertyDefinitions($datasource);
}
$this->properties[$datasource_id] = $properties;
}
return $this->properties[$datasource_id];
}