mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 07:33:50 +00:00
Adding context
This commit is contained in:
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user