lean-api/skeleton/EntityGenerate/FactoryTrait.php

32 lines
1.3 KiB
PHP

<?php
namespace %NAMESPACE%\%FACTORY_TRAIT_NS%;
use %NAMESPACE%\{ %USE_ENTITY_NS%, %USE_FORM_NS%, };
use Picea\Ui\Method\FormContextInterface;
use Picea\Ui\Method\FormInterface;
use Psr\Http\Message\ServerRequestInterface;
use Ulmus\Entity\EntityInterface;
trait %CLASSNAME%Trait
{
public function %SAVE_FORM_CLASSNAME_LC%(EntityInterface|%ENTITY_NS%\%CLASSNAME% $entity): FormInterface
{
return new %FORM_NS%\%SAVE_FORM_CLASSNAME%($this->languageHandler, $this->messageFactory, $entity);
}
public function %SAVE_FORM_CONTEXT_CLASSNAME_LC%(ServerRequestInterface $request, ? string $formName = ''): FormContextInterface
{
return new %FORM_NS%\%SAVE_FORM_CONTEXT_CLASSNAME%($this->languageHandler, $this->messageFactory, $request, $formName);
}
public function %DELETE_FORM_CLASSNAME_LC%(EntityInterface|%ENTITY_NS%\%CLASSNAME% $entity): FormInterface
{
return new %FORM_NS%\%DELETE_FORM_CLASSNAME%($this->languageHandler, $this->messageFactory, $entity);
}
public function %DELETE_FORM_CONTEXT_CLASSNAME_LC%(ServerRequestInterface $request, ? string $formName = ''): FormContextInterface
{
return new %FORM_NS%\%DELETE_FORM_CONTEXT_CLASSNAME%($this->languageHandler, $this->messageFactory, $request, $formName);
}
}