CodeExplorer renderTopicForSearch example
$keys =
$this->
getKeywords();
foreach ($found as $item) { $section_plugin_id =
$item->section_plugin_id;
if (!
isset($plugins[$section_plugin_id])) { $plugins[$section_plugin_id] =
$this->
getSectionPlugin($section_plugin_id);
} if ($plugins[$section_plugin_id]) { $langcode =
$item->langcode;
if (!
isset($languages[$langcode])) { $languages[$langcode] =
$this->languageManager->
getLanguage($item->langcode
);
} $topic =
$plugins[$section_plugin_id]->
renderTopicForSearch($item->topic_id,
$languages[$langcode]);
if ($topic) { if (isset($topic['cacheable_metadata'
])) { $this->
addCacheableDependency($topic['cacheable_metadata'
]);
} $results[] =
[ 'title' =>
$topic['title'
],
'link' =>
$topic['url'
]->
toString(),
'snippet' =>
search_excerpt($keys,
$topic['title'
] . ' ' .
$topic['text'
],
$item->langcode
),
'langcode' =>
$item->langcode,
];
} }