mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +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;
|
namespace Chill\DocGeneratorBundle\Context;
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,11 +22,22 @@ class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
|||||||
* Generate the form that display
|
* Generate the form that display
|
||||||
*/
|
*/
|
||||||
public function getForm($entity) {
|
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
|
$builder->add('members', ChoiceType::class, [
|
||||||
// and configure the form to select member of the family
|
'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
|
* Get the data that will be injected to the generated document
|
||||||
*/
|
*/
|
||||||
public function getData($entity): array {
|
public function getData($entity): array {
|
||||||
$ret = [];
|
$datas = array(
|
||||||
|
'setValue' => array(),
|
||||||
|
'cloneRowAndSetValues' => array()
|
||||||
|
); // TODO CREER UNE CLASSE POUR CA
|
||||||
|
|
||||||
if(get_class($entity) == AccompanyingPeriod::class) {
|
if(get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||||
// TODO mettre ça dans un service
|
$values = array();
|
||||||
$ret = ['AccompanyingPeriod' => $entity];
|
foreach($entity->getAccompanyingPeriodWork()->getPersons() as $person) {
|
||||||
} elseif(get_class($entity) == SocialAction::class) {
|
$i = 1;
|
||||||
$ret = ['SocialAction' => $entity];
|
$values[] = array(
|
||||||
|
'personRowId' => $i,
|
||||||
|
'personFirstName' => $person->getFirstName(),
|
||||||
|
'personLastName' => $person->getLastName(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas['cloneRowAndSetValues'][] = array(
|
||||||
|
'personRowId', $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO AJOUTER LES DONNES DU FORMULAIRE
|
return $datas;
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,14 +68,17 @@ class DocGeneratorTemplateController extends AbstractController
|
|||||||
|
|
||||||
if ($template->getContext() == HouseholdMemberSelectionContext::class) {
|
if ($template->getContext() == HouseholdMemberSelectionContext::class) {
|
||||||
$context = new HouseholdMemberSelectionContext();
|
$context = new HouseholdMemberSelectionContext();
|
||||||
// $datas = $context->getData($entity);
|
$datas = $context->getData($entity);
|
||||||
$datas = [];
|
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception("Not implemented", 1);
|
throw new \Exception("Not implemented", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$templateProcessor = new TemplateProcessor($tmpfname);
|
$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');
|
$tmpfname2 = tempnam(sys_get_temp_dir(), 'DOC_GENERATED');
|
||||||
$templateProcessor->saveAs($tmpfname2);
|
$templateProcessor->saveAs($tmpfname2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user