mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
Data injection in to file on openstack
This commit is contained in:
parent
71e6b356c3
commit
0479ddb42b
@ -3,6 +3,7 @@
|
||||
namespace Chill\DocGeneratorBundle\Context;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
|
||||
/**
|
||||
@ -21,11 +22,22 @@ class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
* Generate the form that display
|
||||
*/
|
||||
public function getForm($entity) {
|
||||
// TODO Get FormFactory and create a form
|
||||
throw new \Exception("No implemented yet", 1);
|
||||
|
||||
$choices = [];
|
||||
if(get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||
foreach ($entity->getAccompanyingPeriodWork()->getPersons() as $person) {
|
||||
$choices[$person->getId()] = $person->getName();
|
||||
}
|
||||
}
|
||||
|
||||
// access to the house hold for the AccompanyingPeriod pr the SocialAction
|
||||
// and configure the form to select member of the family
|
||||
$builder->add('members', ChoiceType::class, [
|
||||
'choices' => $choices,
|
||||
'placeholder' => 'Choose a person',
|
||||
'label' => 'Person to add'
|
||||
]);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,17 +53,26 @@ class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
* Get the data that will be injected to the generated document
|
||||
*/
|
||||
public function getData($entity): array {
|
||||
$ret = [];
|
||||
$datas = array(
|
||||
'setValue' => array(),
|
||||
'cloneRowAndSetValues' => array()
|
||||
); // TODO CREER UNE CLASSE POUR CA
|
||||
|
||||
if(get_class($entity) == AccompanyingPeriod::class) {
|
||||
// TODO mettre ça dans un service
|
||||
$ret = ['AccompanyingPeriod' => $entity];
|
||||
} elseif(get_class($entity) == SocialAction::class) {
|
||||
$ret = ['SocialAction' => $entity];
|
||||
if(get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||
$values = array();
|
||||
foreach($entity->getAccompanyingPeriodWork()->getPersons() as $person) {
|
||||
$i = 1;
|
||||
$values[] = array(
|
||||
'personRowId' => $i,
|
||||
'personFirstName' => $person->getFirstName(),
|
||||
'personLastName' => $person->getLastName(),
|
||||
);
|
||||
}
|
||||
|
||||
$datas['cloneRowAndSetValues'][] = array(
|
||||
'personRowId', $values);
|
||||
}
|
||||
|
||||
// TODO AJOUTER LES DONNES DU FORMULAIRE
|
||||
|
||||
return $ret;
|
||||
return $datas;
|
||||
}
|
||||
}
|
||||
|
@ -68,14 +68,17 @@ class DocGeneratorTemplateController extends AbstractController
|
||||
|
||||
if ($template->getContext() == HouseholdMemberSelectionContext::class) {
|
||||
$context = new HouseholdMemberSelectionContext();
|
||||
// $datas = $context->getData($entity);
|
||||
$datas = [];
|
||||
$datas = $context->getData($entity);
|
||||
} else {
|
||||
throw new \Exception("Not implemented", 1);
|
||||
}
|
||||
|
||||
$templateProcessor = new TemplateProcessor($tmpfname);
|
||||
$templateProcessor->setValues(array('firstname' => 'John', 'lastname' => 'Doe'));
|
||||
|
||||
// TODO foreach ($datas['setValue'] as $key => $value) {
|
||||
foreach ($datas['cloneRowAndSetValues'] as $cloneRowAndSetValues) {
|
||||
$templateProcessor->cloneRowAndSetValues($cloneRowAndSetValues[0], $cloneRowAndSetValues[1]);
|
||||
}
|
||||
|
||||
$tmpfname2 = tempnam(sys_get_temp_dir(), 'DOC_GENERATED');
|
||||
$templateProcessor->saveAs($tmpfname2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user