-
Couldn't load subscription status.
- Fork 37
Description
Es wäre hilfreich, die von YCom definierten Status-Optionen flexibler machen zu können und auch im Label an das Projekt anzupassen.
ycom/install/tablesets/yform_user.json
Line 180 in 096da17
| "choices": "translate:ycom_account_inactive_termination=-3,translate:ycom_account_inactive_logins=-2,translate:ycom_account_inactive=-1,translate:ycom_account_requested=0,translate:ycom_account_confirm=1,translate:ycom_account_active=2", |
"choices": "translate:ycom_account_inactive_termination=-3,translate:ycom_account_inactive_logins=-2,translate:ycom_account_inactive=-1,translate:ycom_account_requested=0,translate:ycom_account_confirm=1,translate:ycom_account_active=2",
In diesem Szenario gibt es verschiedene Gründe, weshalb man einen Status (oder auch nur eine Übersetzung davon) projektspezifisch anpassen möchte und ggf. programmatisch auf den richtigen Wert in einer Konstante zurückgreifen möchte.
Mein Vorschlag wäre dazu:
- Konstanten einsetzen, die widerspiegeln, was die Werte bedeuten, z.B.
User::STATUS_ACTIVATED = 1,User::STATUS_INACTIVE = -1,User::STATUS_REGISTERED = 0,User::STATUS_VERIFIED = 2... - Eine Methode, die Status-Optionen zurückgibt, z.B.
getStatusOptions() - Ein Callable in der YForm-Tabellenfeld-Definition hinterlegen, z.B.
YCom\User::getStatusOptions() - Ein EP innerhalb, der weitere Optionen ergänzt.
Konzeptionell sollte sich alles >= 1 einloggen dürfen, alles <= -1 nicht und 0 ist reserviert für die registriert-aber-Nutzungsbedingungen-fehlen-Variante, wobei sich diese Information m.E. auch im Zeitstempel der Nutzungsbedingungen widerspiegelt.
Beispiel so einer Umsetzung (hier eigene Steuersätze ergänzen - das auf das Thema "Status" münzen):
https://github.com/FriendsOfREDAXO/warehouse/blob/ec6aef56f806731c06852b61f98cd2c051253064/lib/Article.php#L55-L59
public const DEFAULT_TAX_OPTIONS = [
'19' => '19%',
'7' => '7%',
'0' => '0%',
]; public static function getTaxOptions() : array
{
// Statt statischer Werte können zusätzlich über einen Extension Point weitere Steuersätze hinzugefügt werden.
$taxOptions = rex_extension::registerPoint(new rex_extension_point('WAREHOUSE_TAX_OPTIONS', self::DEFAULT_TAX_OPTIONS));
if (!is_array($taxOptions)) {
$taxOptions = self::DEFAULT_TAX_OPTIONS;
}
return $taxOptions;
}// EP für WAREHOUSE_TAX verwenden und weitere Steuersätze hinzufügen
rex_extension::register('WAREHOUSE_TAX_OTIONS', function (rex_extension_point $ep) {
/** @var array<int,string> $taxes */
$taxes = $ep->getSubject();
$taxes[42] = '42%';
krsort($taxes);
return $taxes;
});/cc @j4ceee