Profilseite: Kommentare der Person
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m11s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m30s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m3s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 20:57:09 +00:00
parent 53df8918f6
commit 8a59023569
118 changed files with 620 additions and 438 deletions

View file

@ -0,0 +1,57 @@
<?php
namespace App\Profile;
use App\Models\User;
use App\Plugins\PluginAccess;
use Closure;
use Illuminate\Support\Facades\Log;
use Throwable;
/**
* Zusätzliche Bereiche auf der Profilseite einer Person (/personen/{id}),
* beigesteuert von Plugins – z. B. „Kommentare“ aus den Neuigkeiten.
* Die Vue-Komponente liegt unter plugins-core/<plugin>/resources/js/profile-panels/<Name>.vue
* („<plugin>::Name“).
*/
class ProfilePanels
{
/** @var array<string, array{component: string, sort: int, props: Closure}> */
private array $panels = [];
/**
* @param Closure(User $person, User $viewer): (array<string, mixed>|null) $props null = nicht zeigen
*/
public function add(string $key, string $component, int $sort, Closure $props): void
{
$this->panels[$key] = compact('component', 'sort', 'props');
}
/**
* @return list<array{key: string, component: string, props: array<string, mixed>}>
*/
public function resolve(User $person, User $viewer): array
{
$result = [];
foreach (collect($this->panels)->sortBy('sort') as $key => $panel) {
if (! app(PluginAccess::class)->allows($key, $viewer)) {
continue;
}
try {
$props = ($panel['props'])($person, $viewer);
} catch (Throwable $e) {
Log::error("Profilbereich {$key} fehlgeschlagen: ".$e->getMessage());
continue;
}
if ($props !== null) {
$result[] = ['key' => $key, 'component' => $panel['component'], 'props' => $props];
}
}
return $result;
}
}