Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m52s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m46s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m2s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m31s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m58s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
27 lines
873 B
PHP
27 lines
873 B
PHP
<?php
|
|
|
|
namespace Inhaus\Plugins\Glossar;
|
|
|
|
use App\Models\User;
|
|
use App\Search\GlobalSearch;
|
|
use Inhaus\Plugins\Glossar\Models\GlossaryEntry;
|
|
|
|
/** Suchquelle für die globale Suche */
|
|
class GlossarySearch
|
|
{
|
|
/**
|
|
* @return list<array<string, mixed>>
|
|
*/
|
|
public function __invoke(User $user, string $search, int $limit): array
|
|
{
|
|
$query = GlossaryEntry::query();
|
|
GlobalSearch::whereTerms($query, ['term', 'aliases', 'description'], $search);
|
|
|
|
return $query->orderBy('sort_key')->limit($limit)->get()->map(fn (GlossaryEntry $entry) => [
|
|
'title' => $entry->term.($entry->aliases ? ' ('.$entry->aliases.')' : ''),
|
|
'url' => '/glossar#'.$entry->anchor(),
|
|
'excerpt' => GlobalSearch::excerpt(strip_tags((string) $entry->description), $search),
|
|
'meta' => 'Glossar',
|
|
])->all();
|
|
}
|
|
}
|