Adding context

This commit is contained in:
Marc Ducobu
2021-08-12 23:55:01 +02:00
parent 8df4c93c97
commit cbdf976885
5 changed files with 174 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace Chill\DocGeneratorBundle\Context;
/**
* Interface for context for for document generation
*/
interface DocGeneratorContextInterface
{
/**
* has form
*/
public function hasForm(): bool;
/**
* Generate the form that display
*/
public function getForm($entity);
/**
* True of false which entity supports
*/
public function supports(string $entityClass): bool;
/**
* Get the data that will be injected to the generated document
*/
public function getData($entity): array;
}

View File

@@ -0,0 +1,57 @@
<?php
namespace Chill\DocGeneratorBundle\Context;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
/**
* Context that display a form to select a member of a houseHold
*/
class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
{
/**
* has form
*/
public function hasForm(): bool {
return true;
}
/**
* Generate the form that display
*/
public function getForm($entity) {
// TODO Get FormFactory and create a form
// access to the house hold for the AccompanyingPeriod pr the SocialAction
// and configure the form to select member of the family
}
/**
* True of false which entity supports
*/
public function supports(string $entityClass): bool {
return
($entityClass == AccompanyingPeriod::class) ||
($entityClass == SocialAction::class);
}
/**
* Get the data that will be injected to the generated document
*/
public function getData($entity): array {
$ret = [];
if(get_class($entity) == AccompanyingPeriod::class) {
// TODO mettre ça dans un service
$ret = ['AccompanyingPeriod' => $entity];
} elseif(get_class($entity) == SocialAction::class) {
$ret = ['SocialAction' => $entity];
}
// TODO AJOUTER LES DONNES DU FORMULAIRE
return $ret;
}
}