51 lines
1.5 KiB
PHP
51 lines
1.5 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 $formLanguageHandler,
|
|
protected MessageFactoryInterface $formMessage,
|
|
ServerRequestInterface $formContextRequest,
|
|
? string $formName = null
|
|
) {
|
|
parent::__construct($formContextRequest, $formName);
|
|
}
|
|
|
|
# public function initializeEntity(EntityInterface $entity) : void {}
|
|
|
|
public function lang(string $key, array $variables = [])
|
|
{
|
|
return $this->formLanguageHandler->languageFromKey($key, $variables);
|
|
}
|
|
|
|
public function pushSuccessMessage($key, $variables = []) : void {
|
|
$this->pushMessage($this->formMessage::generateSuccess(
|
|
$this->lang($key, $variables)
|
|
));
|
|
}
|
|
|
|
public function pushWarningMessage($key, $variables = []) : void {
|
|
$this->pushMessage($this->formMessage::generateWarning(
|
|
$this->lang($key, $variables)
|
|
));
|
|
}
|
|
|
|
public function pushErrorMessage($key, $variables = []) : void {
|
|
$this->pushMessage($this->formMessage::generateError(
|
|
$a = $this->lang($key, $variables)
|
|
));
|
|
}
|
|
|
|
public function pushInfoMessage($key, $variables = []) : void {
|
|
$this->pushMessage($this->formMessage::generateInfo(
|
|
$this->lang($key, $variables)
|
|
));
|
|
}
|
|
} |