mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 07:33:50 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,29 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Context;
|
||||
|
||||
/**
|
||||
* Interface for context for for document generation
|
||||
* Interface for context for for document generation.
|
||||
*/
|
||||
interface DocGeneratorContextInterface
|
||||
{
|
||||
/**
|
||||
* has form
|
||||
* Get the data that will be injected to the generated document.
|
||||
*
|
||||
* @param mixed $entity
|
||||
*/
|
||||
public function hasForm(): bool;
|
||||
public function getData($entity): array;
|
||||
|
||||
/**
|
||||
* Generate the form that display
|
||||
* Generate the form that display.
|
||||
*
|
||||
* @param mixed $entity
|
||||
*/
|
||||
public function getForm($entity);
|
||||
|
||||
/**
|
||||
* True of false which entity supports
|
||||
* has form.
|
||||
*/
|
||||
public function supports(string $entityClass): bool;
|
||||
public function hasForm(): bool;
|
||||
|
||||
/**
|
||||
* Get the data that will be injected to the generated document
|
||||
* True of false which entity supports.
|
||||
*/
|
||||
public function getData($entity): array;
|
||||
public function supports(string $entityClass): bool;
|
||||
}
|
||||
|
@@ -1,31 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Context;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Context that display a form to select a member of a houseHold
|
||||
* Context that display a form to select a member of a houseHold.
|
||||
*/
|
||||
class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
{
|
||||
/**
|
||||
* has form
|
||||
* Get the data that will be injected to the generated document.
|
||||
*
|
||||
* @param mixed $entity
|
||||
*/
|
||||
public function hasForm(): bool {
|
||||
return true;
|
||||
public function getData($entity): array
|
||||
{
|
||||
$datas = [
|
||||
'setValues' => [],
|
||||
'cloneRowAndSetValues' => [],
|
||||
];
|
||||
|
||||
$persons = $entity->getAccompanyingPeriodWork()->getPersons();
|
||||
|
||||
if (sizeof($persons) > 0) {
|
||||
$firstPerson = $persons[0];
|
||||
|
||||
$datas['setValues'][] = [
|
||||
'firstPersonFirstName' => $firstPerson->getFirstName(),
|
||||
'firstPersonLastName' => $firstPerson->getLastName(), ];
|
||||
}
|
||||
|
||||
if (get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||
$values = [];
|
||||
|
||||
foreach ($entity->getAccompanyingPeriodWork()->getPersons() as $person) {
|
||||
$i = 1;
|
||||
$values[] = [
|
||||
'personRowId' => $i,
|
||||
'personFirstName' => $person->getFirstName(),
|
||||
'personLastName' => $person->getLastName(),
|
||||
];
|
||||
}
|
||||
|
||||
$datas['cloneRowAndSetValues'][] = [
|
||||
'personRowId', $values, ];
|
||||
}
|
||||
|
||||
return $datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the form that display
|
||||
* Generate the form that display.
|
||||
*
|
||||
* @param mixed $entity
|
||||
*/
|
||||
public function getForm($entity) {
|
||||
throw new \Exception("No implemented yet", 1);
|
||||
|
||||
public function getForm($entity)
|
||||
{
|
||||
throw new Exception('No implemented yet', 1);
|
||||
$choices = [];
|
||||
if(get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||
|
||||
if (get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||
foreach ($entity->getAccompanyingPeriodWork()->getPersons() as $person) {
|
||||
$choices[$person->getId()] = $person->getName();
|
||||
}
|
||||
@@ -34,56 +79,27 @@ class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
$builder->add('members', ChoiceType::class, [
|
||||
'choices' => $choices,
|
||||
'placeholder' => 'Choose a person',
|
||||
'label' => 'Person to add'
|
||||
'label' => 'Person to add',
|
||||
]);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* True of false which entity supports
|
||||
* has form.
|
||||
*/
|
||||
public function supports(string $entityClass): bool {
|
||||
return
|
||||
($entityClass == AccompanyingPeriod::class) ||
|
||||
($entityClass == SocialAction::class);
|
||||
public function hasForm(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data that will be injected to the generated document
|
||||
* True of false which entity supports.
|
||||
*/
|
||||
public function getData($entity): array {
|
||||
$datas = array(
|
||||
'setValues' => array(),
|
||||
'cloneRowAndSetValues' => array()
|
||||
);
|
||||
|
||||
$persons = $entity->getAccompanyingPeriodWork()->getPersons();
|
||||
|
||||
if(sizeof($persons) > 0) {
|
||||
$firstPerson = $persons[0];
|
||||
|
||||
$datas['setValues'][] = array(
|
||||
'firstPersonFirstName' => $firstPerson->getFirstName(),
|
||||
'firstPersonLastName' => $firstPerson->getLastName(),);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
public function supports(string $entityClass): bool
|
||||
{
|
||||
return
|
||||
(AccompanyingPeriod::class == $entityClass)
|
||||
|| (SocialAction::class == $entityClass);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user