add form to doc generation and custom form to admin template configuration

This commit is contained in:
2021-12-01 23:00:02 +01:00
parent 7719d2b073
commit 475b40e896
15 changed files with 484 additions and 108 deletions

View File

@@ -40,6 +40,17 @@ class ContextManager
throw new ContextNotFoundException($docGeneratorTemplate->getContext());
}
public function getContextByKey(string $searchedKey): DocGeneratorContextInterface
{
foreach ($this->contexts as $key => $context) {
if ($searchedKey === $key) {
return $context;
}
}
throw new ContextNotFoundException($searchedKey);
}
public function getContexts(): array
{
return iterator_to_array($this->contexts);

View File

@@ -13,9 +13,10 @@ namespace Chill\DocGeneratorBundle\Context;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\DocStoreBundle\Entity\StoredObject;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Interface for context for for document generation.
* Interface for context for document generation.
*/
interface DocGeneratorContextInterface
{
@@ -24,28 +25,37 @@ interface DocGeneratorContextInterface
*
* @param mixed $entity
*/
public function getData($entity): array;
public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array;
/**
* Generate the form that display.
*
* @param mixed $entity
*/
public function getForm($entity);
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void;
public static function getKey(): string;
public function getName(): string;
public function getDescription(): string;
/**
* has form.
*
* @param mixed $entity
*/
public function hasForm(): bool;
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool;
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity): void;
public function hasAdminForm(): bool;
/**
* True of false which entity supports.
*/
public function supports(string $entityClass): bool;
public function buildAdminForm(FormBuilderInterface $builder): void;
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void;
public function getEntityClass(): string;
public function adminFormTransform(array $data): array;
public function adminFormReverseTransform(array $data): array;
}

View File

@@ -25,7 +25,7 @@ use function get_class;
/**
* Context that display a form to select a member of a houseHold.
*/
class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
class HouseholdMemberSelectionContext //implements DocGeneratorContextInterface
{
private EntityManagerInterface $em;