lean-api/src/Factory/DebugFormFactory.php
2025-05-21 18:36:19 +00:00

39 lines
1.3 KiB
PHP

<?php
namespace Lean\Api\Factory;
use Lean\Api\{Factory, Form, Entity, Lib};
use Lean\LanguageHandler;
use Picea\Ui\Method\FormContextInterface;
use Picea\Ui\Method\FormInterface;
use Psr\Http\Message\ServerRequestInterface;
use Ulmus\Entity\EntityInterface;
class DebugFormFactory implements DebugFormFactoryInterface
{
public function __construct(
protected ServerRequestInterface $request,
protected LanguageHandler $languageHandler,
protected MessageFactoryInterface $messageFactory,
) {}
public function errorSave(EntityInterface|Entity\Error $entity): FormInterface
{
return new Form\Debug\ErrorSave($this->languageHandler, $this->messageFactory, $entity);
}
public function errorSaveContext(? ServerRequestInterface $request = null, ? string $formName = null): FormContextInterface
{
return new Form\Debug\ErrorContext($request ?: $this->request, $formName);
}
public function errorDelete(EntityInterface|Entity\Error $entity): FormInterface
{
return new Form\Debug\ErrorDelete($this->languageHandler, $this->messageFactory, $entity);
}
public function errorDeleteContext(?ServerRequestInterface $request = null, ?string $formName = null): FormContextInterface
{
return new Lib\FormContext($request, $formName);
}
}