- WIP on Forms

This commit is contained in:
mcndave committed 2025-07-17 18:39:57 +00:00
1 parent 2dbcfbcb2e
commit 0e0f004bc1
3 files changed
+47 -4

No files matched your search

+45 -1
View File
@@ -2,4 +2,48 @@
namespace Lean\Api\Lib;
class FormContext extends \Picea\Ui\Method\FormContext { }
use Lean\Api\Factory\MessageFactoryInterface;
use Lean\LanguageHandler;
use Psr\Http\Message\ServerRequestInterface;
class FormContext extends \Picea\Ui\Method\FormContext {
public function __construct(
protected LanguageHandler $languageHandler,
protected MessageFactoryInterface $message,
ServerRequestInterface $request,
? string $formName = null
)
{
parent::__construct($request, $formName);
}
public function lang(string $key, array $variables = [])
{
return $this->languageHandler->languageFromKey($key, $variables);
}
public function pushSuccessMessage($key, $variables = []) {
$this->pushMessage($this->message::generateSuccess(
$this->lang($key, $variables)
));
}
public function pushWarningMessage($key, $variables = []) {
$this->pushMessage($this->message::generateWarning(
$this->lang($key, $variables)
));
}
public function pushErrorMessage($key, $variables = []) {
$this->pushMessage($this->message::generateError(
$this->lang($key, $variables)
));
}
public function pushInfoMessage($key, $variables = []) {
$this->pushMessage($this->message::generateInfo(
$this->lang($key, $variables)
));
}
}