in modules/quanthub_indicator/src/Plugin/search_api/processor/QuanthubIndicatorProcessor.php [256:322]
public function processRenderedItemField(FieldInterface $field, EntityInterface $dataset_entity) {
if ($this->indicatorId) {
$field_values = $field->getValues();
if ($this->langcode && !empty($this->loadedIndicators[$this->datasetUrn][$this->indicatorId])) {
if (!empty($this->loadedIndicators[$this->datasetUrn][$this->indicatorId]['names'][$this->langcode])) {
$indicator_title = $this->loadedIndicators[$this->datasetUrn][$this->indicatorId]['names'][$this->langcode];
}
else {
$indicator_title = $this->loadedIndicators[$this->datasetUrn][$this->indicatorId]['name'];
}
$indicator_uri = Url::fromRoute(
self::EXPLORER_ROUTE,
[],
[
'query' => [
'urn' => $this->datasetUrn,
'filter' => $this->getDimensionsFilterUrl($this->datasetUrn),
],
'language' => $this->language,
]
);
$dataset_uri = $dataset_entity->toLink(
NULL,
'canonical',
[
'class' => [
'indicator-dataset',
'indicator-dataset-link',
],
]
)->toString();
$topics_links = [];
if (!$dataset_entity->field_topics->isEmpty()) {
foreach ($dataset_entity->field_topics->referencedEntities() as $referencedEntity) {
if ($referencedEntity->hasTranslation($this->langcode)) {
$topics_links[] = $referencedEntity->getTranslation($this->langcode)->toLink();
}
}
}
$dataset_bundle_label = NodeType::load('dataset')->label();
$indicator_bundle_label = NodeType::load('indicator')->label();
$indicator_renderable = [
'#theme' => 'quanthub_indicator',
'#indicator_title' => $indicator_title,
'#indicator_uri' => $indicator_uri,
'#indicator_dataset_link' => $dataset_uri,
'#indicator_dataset_bundle_label' => $dataset_bundle_label,
'#indicator_bundle_label' => $indicator_bundle_label,
'#indicator_topics' => $topics_links,
'#indicator_dataset_urn' => $this->datasetUrn,
'#indicator_data_value' => $this->getDimensionsFilterUrl($this->datasetUrn),
'#indicator_parameter' => $this->entity->field_indicator_parameter->getString() ?: QuanthubSdmxClient::STRUCTURE_DIMENSION_ID,
];
$rendered_indicator = $this->renderer->renderPlain($indicator_renderable);
$field_values[0]->setText($rendered_indicator);
$field_values[0]->setOriginalText($rendered_indicator);
$field->setValues($field_values);
}
}
}