52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Lean\Api\Lib;
|
|
|
|
use Lean\Api\Factory\MessageFactoryInterface;
|
|
use Lean\LanguageHandler;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use Ulmus\Entity\EntityInterface;
|
|
|
|
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 initializeEntity(EntityInterface $entity) : void {}
|
|
|
|
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)
|
|
));
|
|
}
|
|
} |