Feste Profilfelder in Formularen, Geburtstage, anpassbare Startseite
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m21s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 3m8s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m43s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m1s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m21s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 3m8s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m43s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m1s
- Formulare: Felder fest aus dem Profil (nicht änderbar, Server setzt den Profilwert ein), Hinweis bei fehlender Profilangabe - Geburtstage (optionales Plugin, standardmäßig aus): Tag und Monat freiwillig im Profil, Kachel, Liste /geburtstage, Pagebuilder-Block, Glückwunsch am eigenen Geburtstag; Sichtbarkeit alle/Abteilung/Standort - Startseite: Kacheln je Bereich sortieren und ausblenden; eigene Kacheln (Bild mit Link, Text, Hinweis) mit Zeitraum und Zielgruppe - Kern: optionale mitgelieferte Plugins, Startseitenbereich „top“, Profilabschnitte für Plugins, Kachel-Bezeichnungen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
435960725d
commit
ee8dde93c0
262 changed files with 2385 additions and 692 deletions
52
app/Profile/ProfileSections.php
Normal file
52
app/Profile/ProfileSections.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Profile;
|
||||
|
||||
use App\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Zusätzliche Abschnitte in „Profil bearbeiten“, beigesteuert von Plugins
|
||||
* (z. B. „Geburtstag“). Die Vue-Komponente liegt unter
|
||||
* plugins-core/<plugin>/resources/js/profile/<Name>.vue („<plugin>::Name“)
|
||||
* und speichert über eigene Routen des Plugins.
|
||||
*/
|
||||
class ProfileSections
|
||||
{
|
||||
/** @var array<string, array{component: string, sort: int, props: Closure}> */
|
||||
private array $sections = [];
|
||||
|
||||
/**
|
||||
* @param Closure(User): (array<string, mixed>|null) $props null = Abschnitt nicht zeigen
|
||||
*/
|
||||
public function add(string $key, string $component, int $sort, Closure $props): void
|
||||
{
|
||||
$this->sections[$key] = compact('component', 'sort', 'props');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{key: string, component: string, props: array<string, mixed>}>
|
||||
*/
|
||||
public function resolve(User $user): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach (collect($this->sections)->sortBy('sort') as $key => $section) {
|
||||
try {
|
||||
$props = ($section['props'])($user);
|
||||
} catch (Throwable $e) {
|
||||
Log::error("Profilabschnitt {$key} fehlgeschlagen: ".$e->getMessage());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($props !== null) {
|
||||
$result[] = ['key' => $key, 'component' => $section['component'], 'props' => $props];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue