mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
79 lines
2.2 KiB
PHP
79 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Chill\DocGeneratorBundle\Context;
|
|
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
|
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) {
|
|
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();
|
|
}
|
|
}
|
|
|
|
$builder->add('members', ChoiceType::class, [
|
|
'choices' => $choices,
|
|
'placeholder' => 'Choose a person',
|
|
'label' => 'Person to add'
|
|
]);
|
|
|
|
return $builder;
|
|
}
|
|
|
|
/**
|
|
* 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 {
|
|
$datas = array(
|
|
'setValue' => array(),
|
|
'cloneRowAndSetValues' => array()
|
|
); // TODO CREER UNE CLASSE POUR CA
|
|
|
|
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);
|
|
}
|
|
|
|
return $datas;
|
|
}
|
|
}
|