cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,5 +1,12 @@
<?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\AMLI\FamilyMembersBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

View File

@@ -1,89 +1,85 @@
<?php
/*
*/
namespace Chill\AMLI\FamilyMembersBundle\Config;
/**
*
* Chill is a software for social workers
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AMLI\FamilyMembersBundle\Config;
class ConfigRepository
{
/**
*
* @var array
*/
protected $links;
/**
*
* @var array
*/
protected $professionalSituations;
/**
*
* @var array
*/
protected $familialSituations;
/**
* @var array
*/
protected $links;
/**
* @var array
*/
protected $professionalSituations;
public function __construct($links, $professionnalSituations, $familialSituations)
{
$this->links = $links;
$this->professionalSituations = $professionnalSituations ?? [];
$this->familialSituations = $familialSituations ?? [];
}
public function getFamilialSituationsLabels()
{
return $this->normalizeConfig($this->familialSituations);
}
/**
*
* @return array where keys are the link's keys and label the links label
*/
public function getLinksLabels()
{
return $this->normalizeConfig($this->links);
}
public function getProfessionalSituationsLabels()
{
return $this->normalizeConfig($this->professionalSituations);
}
public function hasProfessionalSituation(): bool
{
return count($this->professionalSituations) > 0;
}
public function getFamilialSituationsLabels()
{
return $this->normalizeConfig($this->familialSituations);
}
public function hasFamilialSituation(): bool
{
return count($this->familialSituations) > 0;
}
public function hasProfessionalSituation(): bool
{
return count($this->professionalSituations) > 0;
}
private function normalizeConfig($config)
{
$els = array();
$els = [];
foreach ($config as $definition) {
$els[$definition['key']] = $this->normalizeLabel($definition['labels']);
}
return $els;
}
private function normalizeLabel($labels)
private function normalizeLabel($labels)
{
$normalizedLabels = array();
$normalizedLabels = [];
foreach ($labels as $labelDefinition) {
$normalizedLabels[$labelDefinition['lang']] = $labelDefinition['label'];
}
return $normalizedLabels;
}
}

View File

@@ -1,31 +1,38 @@
<?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.
*/
declare(strict_types=1);
namespace Chill\AMLI\FamilyMembersBundle\Controller;
use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember;
use Chill\AMLI\FamilyMembersBundle\Form\FamilyMemberType;
use Chill\AMLI\FamilyMembersBundle\Repository\FamilyMemberRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Chill\AMLI\FamilyMembersBundle\Security\Voter\FamilyMemberVoter;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember;
use Chill\AMLI\FamilyMembersBundle\Security\Voter\FamilyMemberVoter;
use Chill\AMLI\FamilyMembersBundle\Form\FamilyMemberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
class FamilyMemberController extends AbstractController
{
private EntityManagerInterface $em;
protected LoggerInterface $chillMainLogger;
protected TranslatorInterface $translator;
protected LoggerInterface $chillMainLogger;
private EntityManagerInterface $em;
private FamilyMemberRepository $familyMemberRepository;
@@ -43,8 +50,82 @@ class FamilyMemberController extends AbstractController
/**
* @Route(
* "{_locale}/family-members/family-members/by-person/{id}",
* name="chill_family_members_family_members_index"
* "{_locale}/family-members/family-members/{id}/delete",
* name="chill_family_members_family_members_delete"
* )
*/
public function deleteAction(FamilyMember $familyMember, Request $request): Response
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::DELETE, $familyMember, 'You are not '
. 'allowed to delete this family membership');
$form = $this->createDeleteForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
$form->handleRequest($request);
if ($form->isValid()) {
$this->chillMainLogger->notice('A family member has been removed', [
'by_user' => $this->getUser()->getUsername(),
'family_member_id' => $familyMember->getId(),
'name' => $familyMember->getFirstname() . ' ' . $familyMember->getLastname(),
'link' => $familyMember->getLink(),
]);
$this->em->remove($familyMember);
$this->em->flush();
$this->addFlash('success', $this->translator
->trans('The family member has been successfully removed.'));
return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $familyMember->getPerson()->getId(),
]);
}
}
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:confirm_delete.html.twig', [
'familyMember' => $familyMember,
'delete_form' => $form->createView(),
]);
}
/**
* @Route(
* "{_locale}/family-members/family-members/{id}/edit",
* name="chill_family_members_family_members_edit"
* )
*/
public function editAction(FamilyMember $familyMember, Request $request)
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::UPDATE, $familyMember);
$form = $this->createForm(FamilyMemberType::class, $familyMember);
$form->add('submit', SubmitType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->em->flush();
$this->addFlash('success', $this->translator->trans('Family member updated'));
return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $familyMember->getPerson()->getId(),
]);
}
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:edit.html.twig', [
'familyMember' => $familyMember,
'form' => $form->createView(),
'person' => $familyMember->getPerson(),
]);
}
/**
* @Route(
* "{_locale}/family-members/family-members/by-person/{id}",
* name="chill_family_members_family_members_index"
* )
*/
public function indexAction(Person $person)
@@ -55,14 +136,14 @@ class FamilyMemberController extends AbstractController
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:index.html.twig', [
'person' => $person,
'familyMembers' => $familyMembers
'familyMembers' => $familyMembers,
]);
}
/**
* @Route(
* "{_locale}/family-members/family-members/by-person/{id}/new",
* name="chill_family_members_family_members_new"
* "{_locale}/family-members/family-members/by-person/{id}/new",
* name="chill_family_members_family_members_new"
* )
*/
public function newAction(Person $person, Request $request)
@@ -83,96 +164,20 @@ class FamilyMemberController extends AbstractController
$this->addFlash('success', $this->translator->trans('Family member created'));
return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $person->getId()
'id' => $person->getId(),
]);
}
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:new.html.twig', [
'form' => $form->createView(),
'person' => $person
'person' => $person,
]);
}
/**
* @Route(
* "{_locale}/family-members/family-members/{id}/edit",
* name="chill_family_members_family_members_edit"
* )
*/
public function editAction(FamilyMember $familyMember, Request $request)
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::UPDATE, $familyMember);
$form = $this->createForm(FamilyMemberType::class, $familyMember);
$form->add('submit', SubmitType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->em->flush();
$this->addFlash('success', $this->translator->trans('Family member updated'));
return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $familyMember->getPerson()->getId()
]);
}
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:edit.html.twig', [
'familyMember' => $familyMember,
'form' => $form->createView(),
'person' => $familyMember->getPerson()
]);
}
/**
*
* @Route(
* "{_locale}/family-members/family-members/{id}/delete",
* name="chill_family_members_family_members_delete"
* )
*/
public function deleteAction(FamilyMember $familyMember, Request $request): Response
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::DELETE, $familyMember, 'You are not '
. 'allowed to delete this family membership');
$form = $this->createDeleteForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
$form->handleRequest($request);
if ($form->isValid()) {
$this->chillMainLogger->notice("A family member has been removed", [
'by_user' => $this->getUser()->getUsername(),
'family_member_id' => $familyMember->getId(),
'name' => $familyMember->getFirstname()." ".$familyMember->getLastname(),
'link' => $familyMember->getLink()
]);
$this->em->remove($familyMember);
$this->em->flush();
$this->addFlash('success', $this->translator
->trans("The family member has been successfully removed."));
return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $familyMember->getPerson()->getId()
]);
}
}
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:confirm_delete.html.twig', [
'familyMember' => $familyMember,
'delete_form' => $form->createView()
]);
}
/**
* @Route(
* "{_locale}/family-members/family-members/{id}/view",
* name="chill_family_members_family_members_view"
* "{_locale}/family-members/family-members/{id}/view",
* name="chill_family_members_family_members_view"
* )
*/
public function viewAction(FamilyMember $familyMember)
@@ -180,7 +185,7 @@ class FamilyMemberController extends AbstractController
$this->denyAccessUnlessGranted(FamilyMemberVoter::SHOW, $familyMember);
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:view.html.twig', [
'familyMember' => $familyMember
'familyMember' => $familyMember,
]);
}
@@ -193,8 +198,6 @@ class FamilyMemberController extends AbstractController
->createFormBuilder()
->setMethod(Request::METHOD_DELETE)
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm()
;
->getForm();
}
}

View File

@@ -1,32 +1,36 @@
<?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\AMLI\FamilyMembersBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Chill\AMLI\FamilyMembersBundle\Security\Voter\FamilyMemberVoter;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* This is the class that loads and manages your bundle configuration.
*
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
* @see http://symfony.com/doc/current/cookbook/bundles/extension.html
*/
class ChillAMLIFamilyMembersExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$this->storeConfig($container, $config);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services/config.yml');
$loader->load('services/form.yml');
$loader->load('services/controller.yml');
@@ -34,45 +38,48 @@ class ChillAMLIFamilyMembersExtension extends Extension implements PrependExtens
$loader->load('services/menu.yml');
$loader->load('services/templating.yml');
}
private function storeConfig(ContainerBuilder $container, array $config)
{
$container->setParameter('chill_family_members.links', $config['links']);
$container->setParameter('chill_family_members.professionnal_situations',
$config['professionnal_situations']);
$container->setParameter('chill_family_members.familial_situations',
$config['familial_situations']);
}
public function prepend(ContainerBuilder $container)
{
$this->prependAuthorization($container);
$this->prependRoutes($container);
}
protected function prependAuthorization(ContainerBuilder $container)
{
$container->prependExtensionConfig('security', array(
'role_hierarchy' => array(
FamilyMemberVoter::UPDATE => [FamilyMemberVoter::SHOW],
FamilyMemberVoter::CREATE => [FamilyMemberVoter::SHOW]
)
));
}
/* (non-PHPdoc)
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
*/
public function prependRoutes(ContainerBuilder $container)
public function prependRoutes(ContainerBuilder $container)
{
//add routes for custom bundle
$container->prependExtensionConfig('chill_main', array(
'routing' => array(
'resources' => array(
'@ChillAMLIFamilyMembersBundle/Resources/config/routing.yml'
)
)
));
$container->prependExtensionConfig('chill_main', [
'routing' => [
'resources' => [
'@ChillAMLIFamilyMembersBundle/Resources/config/routing.yml',
],
],
]);
}
protected function prependAuthorization(ContainerBuilder $container)
{
$container->prependExtensionConfig('security', [
'role_hierarchy' => [
FamilyMemberVoter::UPDATE => [FamilyMemberVoter::SHOW],
FamilyMemberVoter::CREATE => [FamilyMemberVoter::SHOW],
],
]);
}
private function storeConfig(ContainerBuilder $container, array $config)
{
$container->setParameter('chill_family_members.links', $config['links']);
$container->setParameter(
'chill_family_members.professionnal_situations',
$config['professionnal_situations']
);
$container->setParameter(
'chill_family_members.familial_situations',
$config['familial_situations']
);
}
}

View File

@@ -1,5 +1,12 @@
<?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\AMLI\FamilyMembersBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
@@ -12,9 +19,6 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('chill_amli_family_members');
@@ -22,74 +26,73 @@ class Configuration implements ConfigurationInterface
$rootNode
->children()
->arrayNode('links')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('key')->isRequired()->cannotBeEmpty()
->info('the key stored in database')
->example('grandson')
->end()
->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('lang')->isRequired()->cannotBeEmpty()
->example('fr')
->end()
->scalarNode('label')->isRequired()->cannotBeEmpty()
->example('Petit-fils')
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('professionnal_situations')->isRequired()
->info("the list of professional situations. If empty, the field will not be shown")
->arrayPrototype()
->children()
->scalarNode('key')->isRequired()->cannotBeEmpty()
->info('the key stored in database')
->example('student')
->end()
->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('lang')->isRequired()->cannotBeEmpty()
->example('fr')
->end()
->scalarNode('label')->isRequired()->cannotBeEmpty()
->example('Étudiant')
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('familial_situations')->isRequired()
->info("the list of familial situations. If empty, the field will not be shown")
->arrayPrototype()
->children()
->scalarNode('key')->isRequired()->cannotBeEmpty()
->info('the key stored in database')
->example('half_time_keeping')
->end()
->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('lang')->isRequired()->cannotBeEmpty()
->example('fr')
->end()
->scalarNode('label')->isRequired()->cannotBeEmpty()
->example('En garde alternée')
->end()
->end()
->end()
->end()
->end()
->end()
;
->arrayNode('links')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('key')->isRequired()->cannotBeEmpty()
->info('the key stored in database')
->example('grandson')
->end()
->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('lang')->isRequired()->cannotBeEmpty()
->example('fr')
->end()
->scalarNode('label')->isRequired()->cannotBeEmpty()
->example('Petit-fils')
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('professionnal_situations')->isRequired()
->info('the list of professional situations. If empty, the field will not be shown')
->arrayPrototype()
->children()
->scalarNode('key')->isRequired()->cannotBeEmpty()
->info('the key stored in database')
->example('student')
->end()
->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('lang')->isRequired()->cannotBeEmpty()
->example('fr')
->end()
->scalarNode('label')->isRequired()->cannotBeEmpty()
->example('Étudiant')
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('familial_situations')->isRequired()
->info('the list of familial situations. If empty, the field will not be shown')
->arrayPrototype()
->children()
->scalarNode('key')->isRequired()->cannotBeEmpty()
->info('the key stored in database')
->example('half_time_keeping')
->end()
->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
->arrayPrototype()
->children()
->scalarNode('lang')->isRequired()->cannotBeEmpty()
->example('fr')
->end()
->scalarNode('label')->isRequired()->cannotBeEmpty()
->example('En garde alternée')
->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
}

View File

@@ -1,53 +1,60 @@
<?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\AMLI\FamilyMembersBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\MaritalStatus;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\PersonBundle\Entity\MaritalStatus;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
*
* @ORM\MappedSuperclass()
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* @ORM\MappedSuperclass
*/
abstract class AbstractFamilyMember implements HasCenterInterface
{
const FAMILIAL_SITUATION = [
'a_charge'=> 'A charge',
'garde_alternee'=> 'Garde alternée',
'droit_de_visite'=> 'Droit de visite et d\'hébergement',
'non_a_charge' => 'Non à charge',
];
public const FAMILIAL_SITUATION = [
'a_charge' => 'A charge',
'garde_alternee' => 'Garde alternée',
'droit_de_visite' => 'Droit de visite et d\'hébergement',
'non_a_charge' => 'Non à charge',
];
/**
*
* @var Person
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
*/
private $person;
/**
* @var date_immutable|null
*
* @var MaritalStatus
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\MaritalStatus"
* @ORM\Column(name="birthdate", type="date_immutable", nullable=true)
* @Assert\Date
*/
private $birthdate;
/**
* @var DateTimeImmutable|null
*
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
* @Assert\Date
* @Assert\GreaterThan(
* propertyPath="startDate",
* message="The membership's end date should be after the start date"
* )
*/
private $maritalStatus;
private $endDate;
/**
* @var string
*
* @ORM\Column(name="lastname", type="string", length=255)
* @ORM\Column(name="familial_situation", type="string", length=200, nullable=true)
*/
private $lastname = '';
private $familialSituation;
/**
* @var string
@@ -64,12 +71,34 @@ abstract class AbstractFamilyMember implements HasCenterInterface
private $gender = '';
/**
* @var date_immutable|null
* @var string
*
* @ORM\Column(name="birthdate", type="date_immutable", nullable=true)
* @Assert\Date()
* @ORM\Column(name="lastname", type="string", length=255)
*/
private $birthdate;
private $lastname = '';
/**
* @var string
*
* @ORM\Column(name="link", type="string", length=255)
*/
private $link = '';
/**
* @var MaritalStatus
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\MaritalStatus"
* )
*/
private $maritalStatus;
/**
* @var Person
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
*/
private $person;
/**
* @var string
@@ -79,57 +108,67 @@ abstract class AbstractFamilyMember implements HasCenterInterface
private $professionnalSituation = '';
/**
* @var string
*
* @ORM\Column(name="link", type="string", length=255)
*/
private $link = '';
/**
*
* @var string
* @ORM\Column(name="familial_situation", type="string", length=200, nullable=true)
*/
private $familialSituation;
/**
* @var \DateTimeImmutable
* @var DateTimeImmutable
*
* @ORM\Column(name="startDate", type="datetime_immutable")
* @Assert\NotNull()
* @Assert\Date()
* @Assert\NotNull
* @Assert\Date
*/
private $startDate;
/**
* @var \DateTimeImmutable|null
*
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
* @Assert\Date()
* @Assert\GreaterThan(
* propertyPath="startDate",
* message="The membership's end date should be after the start date"
* )
*/
private $endDate;
public function __construct()
{
$this->setStartDate(new \DateTimeImmutable('now'));
$this->setStartDate(new DateTimeImmutable('now'));
}
/**
* Set lastname.
*
* @param string $lastname
*
* @return FamilyMember
*/
public function setLastname($lastname)
{
$this->lastname = (string) $lastname;
return $this;
/**
* Get birthdate.
*
* @return date_immutable|null
*/
public function getBirthdate()
{
return $this->birthdate;
}
public function getCenter(): \Chill\MainBundle\Entity\Center
{
return $this->getPerson()->getCenter();
}
/**
* Get endDate.
*
* @return DateTimeImmutable|null
*/
public function getEndDate()
{
return $this->endDate;
}
public function getFamilialSituation()
{
return $this->familialSituation;
}
/**
* Get firstname.
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Get gender.
*
* @return string
*/
public function getGender()
{
return $this->gender;
}
/**
@@ -142,6 +181,91 @@ abstract class AbstractFamilyMember implements HasCenterInterface
return $this->lastname;
}
/**
* Get link.
*
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* @return MaritalStatus
*/
public function getMaritalStatus()
{
return $this->maritalStatus;
}
/**
* @return Person
*/
public function getPerson()
{
return $this->person;
}
/**
* Get professionnalSituation.
*
* @return string
*/
public function getProfessionnalSituation()
{
return $this->professionnalSituation;
}
/**
* Get startDate.
*
* @return DateTimeImmutable
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set birthdate.
*
* @return FamilyMember
*/
public function setBirthdate(?DateTimeInterface $birthdate = null)
{
if ($birthdate instanceof DateTime) {
$this->birthdate = DateTimeImmutable::createFromMutable($birthdate);
} elseif (null === $birthdate || $birthdate instanceof DateTimeImmutable) {
$this->birthdate = $birthdate;
}
return $this;
}
/**
* Set endDate.
*
* @return FamilyMember
*/
public function setEndDate(?DateTimeInterface $endDate = null)
{
if ($endDate instanceof DateTime) {
$this->endDate = DateTimeImmutable::createFromMutable($endDate);
} elseif ($endDate instanceof DateTimeImmutable || null === $endDate) {
$this->endDate = $endDate;
}
return $this;
}
public function setFamilialSituation($familialSituation)
{
$this->familialSituation = $familialSituation;
return $this;
}
/**
* Set firstname.
*
@@ -156,16 +280,6 @@ abstract class AbstractFamilyMember implements HasCenterInterface
return $this;
}
/**
* Get firstname.
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set gender.
*
@@ -181,67 +295,19 @@ abstract class AbstractFamilyMember implements HasCenterInterface
}
/**
* Get gender.
* Set lastname.
*
* @return string
*/
public function getGender()
{
return $this->gender;
}
/**
* Set birthdate.
*
* @param \DateTimeInterface|null $birthdate
* @param string $lastname
*
* @return FamilyMember
*/
public function setBirthdate(\DateTimeInterface $birthdate = null)
public function setLastname($lastname)
{
if ($birthdate instanceof \DateTime) {
$this->birthdate = \DateTimeImmutable::createFromMutable($birthdate);
} elseif ($birthdate === null || $birthdate instanceof \DateTimeImmutable) {
$this->birthdate = $birthdate;
}
$this->lastname = (string) $lastname;
return $this;
}
/**
* Get birthdate.
*
* @return date_immutable|null
*/
public function getBirthdate()
{
return $this->birthdate;
}
/**
* Set professionnalSituation.
*
* @param string $professionnalSituation
*
* @return FamilyMember
*/
public function setProfessionnalSituation($professionnalSituation)
{
$this->professionnalSituation = (string) $professionnalSituation;
return $this;
}
/**
* Get professionnalSituation.
*
* @return string
*/
public function getProfessionnalSituation()
{
return $this->professionnalSituation;
}
/**
* Set link.
*
@@ -257,127 +323,56 @@ abstract class AbstractFamilyMember implements HasCenterInterface
}
/**
* Get link.
* @param MaritalStatus $maritalStatus
*
* @return string
* @return $this
*/
public function getLink()
public function setMaritalStatus(?MaritalStatus $maritalStatus = null)
{
return $this->link;
}
public function getFamilialSituation()
{
return $this->familialSituation;
}
public function setFamilialSituation($familialSituation)
{
$this->familialSituation = $familialSituation;
return $this;
}
/**
* Set startDate.
*
* @param \DateTimeImmutable $startDate
*
* @return FamilyMember
*/
public function setStartDate(\DateTimeInterface $startDate)
{
if ($startDate instanceof \DateTime) {
$this->startDate = \DateTimeImmutable::createFromMutable($startDate);
} elseif (NULL === $startDate || $startDate instanceof \DateTimeImmutable) {
$this->startDate = $startDate;
}
$this->maritalStatus = $maritalStatus;
return $this;
}
/**
* Get startDate.
*
* @return \DateTimeImmutable
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set endDate.
*
* @param \DateTimeInterface|null $endDate
*
* @return FamilyMember
*/
public function setEndDate(\DateTimeInterface $endDate = null)
{
if ($endDate instanceof \DateTime) {
$this->endDate = \DateTimeImmutable::createFromMutable($endDate);
} elseif ($endDate instanceof \DateTimeImmutable || $endDate === null) {
$this->endDate = $endDate;
}
return $this;
}
/**
* Get endDate.
*
* @return \DateTimeImmutable|null
*/
public function getEndDate()
{
return $this->endDate;
}
/**
*
* @return Person
*/
public function getPerson()
{
return $this->person;
}
/**
*
* @return MaritalStatus
*/
public function getMaritalStatus()
{
return $this->maritalStatus;
}
/**
*
* @param Person $person
* @return $this
*/
public function setPerson(Person $person)
{
$this->person = $person;
return $this;
}
/**
*
* @param MaritalStatus $maritalStatus
* @return $this
* Set professionnalSituation.
*
* @param string $professionnalSituation
*
* @return FamilyMember
*/
public function setMaritalStatus(MaritalStatus $maritalStatus = null)
public function setProfessionnalSituation($professionnalSituation)
{
$this->maritalStatus = $maritalStatus;
$this->professionnalSituation = (string) $professionnalSituation;
return $this;
}
public function getCenter(): \Chill\MainBundle\Entity\Center
/**
* Set startDate.
*
* @param DateTimeImmutable $startDate
*
* @return FamilyMember
*/
public function setStartDate(DateTimeInterface $startDate)
{
return $this->getPerson()->getCenter();
if ($startDate instanceof DateTime) {
$this->startDate = DateTimeImmutable::createFromMutable($startDate);
} elseif (null === $startDate || $startDate instanceof DateTimeImmutable) {
$this->startDate = $startDate;
}
return $this;
}
}

View File

@@ -1,11 +1,18 @@
<?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\AMLI\FamilyMembersBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* FamilyMember
* FamilyMember.
*
* @ORM\Table(name="chill_family.family_member")
* @ORM\Entity(repositoryClass="Chill\AMLI\FamilyMembersBundle\Repository\FamilyMemberRepository")

View File

@@ -1,144 +1,133 @@
<?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\AMLI\FamilyMembersBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\PersonBundle\Form\Type\GenderType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
use Chill\AMLI\FamilyMembersBundle\Config\ConfigRepository;
use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\AMLI\AssignmentBundle\Entity\AbstractDiagnosticNIAssignment;
use Chill\AMLI\FamilyMembersBundle\Entity\AbstractFamilyMember;
use Chill\PersonBundle\Form\Type\GenderType;
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class FamilyMemberType extends AbstractType
{
/**
*
* @var ConfigRepository
*/
private $configRepository;
/**
*
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
public function __construct(
ConfigRepository $configRepository,
ConfigRepository $configRepository,
TranslatableStringHelper $translatableStringHelper
) {
$this->configRepository = $configRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('lastname', TextType::class, [
'label' => 'Last name'
'label' => 'Last name',
])
->add('firstname', TextType::class, [
'label' => 'First name'
'label' => 'First name',
])
->add('gender', GenderType::class)
->add('birthdate', ChillDateType::class, [
'required' => false
'required' => false,
])
->add('link', ChoiceType::class, [
'choices' => $this->buildChoices($this->configRepository->getLinksLabels()),
'placeholder' => 'Choose a link',
'label' => 'Relationship'
'label' => 'Relationship',
])
->add('maritalStatus', Select2MaritalStatusType::class, [
'required' => false
])
;
'required' => false,
]);
if ($this->configRepository->hasProfessionalSituation()) {
$builder
->add('professionnalSituation', ChoiceType::class, [
'required' => false,
'choices' => $this->buildChoices(
$this->configRepository->getProfessionalSituationsLabels()
)
]);
->add('professionnalSituation', ChoiceType::class, [
'required' => false,
'choices' => $this->buildChoices(
$this->configRepository->getProfessionalSituationsLabels()
),
]);
}
if ($this->configRepository->hasProfessionalSituation()) {
$builder
->add('familialSituation', ChoiceType::class, [
'required' => false,
'choices' => $this->buildChoices(
$this->configRepository->getFamilialSituationsLabels()
)
]);
->add('familialSituation', ChoiceType::class, [
'required' => false,
'choices' => $this->buildChoices(
$this->configRepository->getFamilialSituationsLabels()
),
]);
}
if ($options['show_start_date']) {
$builder
->add('startDate', ChillDateType::class, [
'label' => 'Arrival date in the family'
'label' => 'Arrival date in the family',
]);
}
if ($options['show_end_date']) {
$builder
->add('endDate', ChillDateType::class, [
'required' => false,
'label' => 'Departure date of the family'
'label' => 'Departure date of the family',
]);
}
}
}/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => FamilyMember::class,
'show_start_date' => true,
'show_end_date' => true,
));
]);
$resolver
->setAllowedTypes('show_start_date', 'boolean')
->setAllowedTypes('show_end_date', 'boolean')
;
}
private function buildChoices($els)
{
$links = $this->configRepository
->getLinksLabels();
$choices = [];
// rewrite labels to filter in language
foreach ($els as $key => $labels) {
$choices[$this->translatableStringHelper->localize($labels)] = $key;
}
return $choices;
->setAllowedTypes('show_end_date', 'boolean');
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'chill_amli_familymembersbundle_familymember';
}
private function buildChoices($els)
{
$links = $this->configRepository
->getLinksLabels();
$choices = [];
// rewrite labels to filter in language
foreach ($els as $key => $labels) {
$choices[$this->translatableStringHelper->localize($labels)] = $key;
}
return $choices;
}
}

View File

@@ -1,18 +1,18 @@
<?php
/*
*/
namespace Chill\AMLI\FamilyMembersBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Chill\MainBundle\Form\Type\ChillCollectionType;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
*
* Chill is a software for social workers
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AMLI\FamilyMembersBundle\Form;
use Chill\MainBundle\Form\Type\ChillCollectionType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class FamilyMembersType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
@@ -21,15 +21,15 @@ class FamilyMembersType extends AbstractType
'entry_type' => FamilyMemberType::class,
'entry_options' => [
'show_start_date' => true,
'show_end_date' => true
'show_end_date' => true,
],
'allow_add' => true,
'allow_delete' => true,
'button_add_label' => 'Ajouter un membre',
'button_remove_label' => 'Enlever ce membre'
'button_remove_label' => 'Enlever ce membre',
]);
}
public function getParent()
{
return ChillCollectionType::class;

View File

@@ -1,61 +1,59 @@
<?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\AMLI\FamilyMembersBundle\Menu;
use Chill\AMLI\FamilyMembersBundle\Security\Voter\FamilyMemberVoter;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Chill\AMLI\FamilyMembersBundle\Security\Voter\FamilyMemberVoter;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Translation\TranslatorInterface;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class UserMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
/**
*
* @var TranslatorInterface
*/
protected $translator;
public function __construct(
AuthorizationCheckerInterface $authorizationChecker,
AuthorizationCheckerInterface $authorizationChecker,
TranslatorInterface $translator
) {
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
/* @var $person \Chill\PersonBundle\Entity\Person */
$person = $parameters['person'];
if ($this->authorizationChecker->isGranted(FamilyMemberVoter::SHOW, $person)) {
$menu->addChild(
$this->translator->trans('Family memberships'), [
$this->translator->trans('Family memberships'),
[
'route' => 'chill_family_members_family_members_index',
'routeParameters' => [ 'id' => $person->getId() ],
])
->setExtra('order', 450)
;
'routeParameters' => ['id' => $person->getId()],
]
)
->setExtra('order', 450);
}
}
public static function getMenuIds(): array
{
return [ 'person' ];
return ['person'];
}
}

View File

@@ -1,5 +1,12 @@
<?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.
*/
declare(strict_types=1);
namespace Chill\AMLI\FamilyMembersBundle\Repository;

View File

@@ -1,4 +1,13 @@
<?php declare(strict_types=1);
<?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.
*/
declare(strict_types=1);
namespace Application\Migrations;
@@ -6,11 +15,18 @@ use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* create schema for chill_family
* create schema for chill_family.
*/
final class Version20180522142023 extends AbstractMigration
{
public function up(Schema $schema) : void
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP SCHEMA chill_family CASCADE');
}
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@@ -25,12 +41,4 @@ final class Version20180522142023 extends AbstractMigration
$this->addSql('ALTER TABLE chill_family.family_member ADD CONSTRAINT FK_A61F4A49217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_family.family_member ADD CONSTRAINT FK_A61F4A49D7D03CE3 FOREIGN KEY (maritalStatus_id) REFERENCES chill_person_marital_status (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP SCHEMA chill_family CASCADE');
}
}

View File

@@ -1,37 +1,41 @@
<?php
/*
*/
namespace Chill\AMLI\FamilyMembersBundle\Security\Voter;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Entity\User;
use Symfony\Component\Security\Core\Role\Role;
/**
* Chill is a software for social workers
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AMLI\FamilyMembersBundle\Security\Voter;
use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Role\Role;
use function in_array;
class FamilyMemberVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
const CREATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_CREATE';
const DELETE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_DELETE';
const UPDATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_UPDATE';
const SHOW = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_SHOW';
public const CREATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_CREATE';
const ROLES = [
public const DELETE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_DELETE';
public const ROLES = [
self::CREATE,
self::DELETE,
self::SHOW,
self::UPDATE
self::UPDATE,
];
public const SHOW = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_SHOW';
public const UPDATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_UPDATE';
/**
*
* @var AuthorizationHelper
*/
protected $authorizationHelper;
@@ -41,26 +45,6 @@ class FamilyMemberVoter extends AbstractChillVoter implements ProvideRoleHierarc
$this->authorizationHelper = $authorizationHelper;
}
protected function supports($attribute, $subject)
{
return (\in_array($attribute, self::ROLES) && $subject instanceof FamilyMember)
or
($subject instanceof Person && \in_array($attribute, [ self::SHOW, self::CREATE ]));
}
protected function voteOnAttribute($attribute, $subject, \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token)
{
$user = $token->getUser();
if (FALSE === $user instanceof User) {
return false;
}
return $this->authorizationHelper
->userHasAccess($user, $subject, new Role($attribute));
}
public function getRoles(): array
{
return self::ROLES;
@@ -76,4 +60,21 @@ class FamilyMemberVoter extends AbstractChillVoter implements ProvideRoleHierarc
return self::ROLES;
}
protected function supports($attribute, $subject)
{
return (in_array($attribute, self::ROLES) && $subject instanceof FamilyMember)
or ($subject instanceof Person && in_array($attribute, [self::SHOW, self::CREATE]));
}
protected function voteOnAttribute($attribute, $subject, \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token)
{
$user = $token->getUser();
if (false === $user instanceof User) {
return false;
}
return $this->authorizationHelper
->userHasAccess($user, $subject, new Role($attribute));
}
}

View File

@@ -1,102 +1,97 @@
<?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\AMLI\FamilyMembersBundle\Templating;
use Twig\Extension\AbstractExtension;
use Chill\AMLI\FamilyMembersBundle\Config\ConfigRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class Twig extends AbstractExtension
{
/**
*
* @var ConfigRepository
*/
protected $configRepository;
/**
*
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
public function __construct(
ConfigRepository $configRepository,
ConfigRepository $configRepository,
TranslatableStringHelper $translatableStringHelper
) {
$this->configRepository = $configRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
public function displayFamilialSituation($situation)
{
if (null === $situation) {
return null;
}
return $this->translatableStringHelper->localize(
$this->configRepository->getFamilialSituationsLabels()[$situation]
);
}
public function displayLink($link)
{
if (null === $link) {
return null;
}
return $this->translatableStringHelper->localize(
$this->configRepository->getLinksLabels()[$link]
);
}
public function displayProfessionalSituation($situation)
{
if (null === $situation) {
return null;
}
return $this->translatableStringHelper->localize(
$this->configRepository->getProfessionalSituationsLabels()[$situation]
);
}
public function getFilters()
{
return [
new TwigFilter('chill_family_member_link_display', [ $this, 'displayLink' ], [ 'is_safe' => [ 'html' ]]),
new TwigFilter('chill_family_member_professional_situation_display', [ $this, 'displayProfessionalSituation' ], [ 'is_safe' => [ 'html' ]]),
new TwigFilter('chill_family_member_familial_situation_display', [ $this, 'displayFamilialSituation' ], [ 'is_safe' => [ 'html' ]]),
new TwigFilter('chill_family_member_link_display', [$this, 'displayLink'], ['is_safe' => ['html']]),
new TwigFilter('chill_family_member_professional_situation_display', [$this, 'displayProfessionalSituation'], ['is_safe' => ['html']]),
new TwigFilter('chill_family_member_familial_situation_display', [$this, 'displayFamilialSituation'], ['is_safe' => ['html']]),
];
}
public function getFunctions()
{
return [
new TwigFunction('chill_family_members_has_professionnal_situation', [ $this, 'hasProfessionnalSituation' ]),
new TwigFunction('chill_family_members_has_familial_situation', [ $this, 'hasFamilialSituation' ]),
new TwigFunction('chill_family_members_has_professionnal_situation', [$this, 'hasProfessionnalSituation']),
new TwigFunction('chill_family_members_has_familial_situation', [$this, 'hasFamilialSituation']),
];
}
public function displayLink($link)
{
if (NULL === $link) {
return null;
}
return $this->translatableStringHelper->localize(
$this->configRepository->getLinksLabels()[$link]
);
}
public function displayProfessionalSituation($situation)
{
if (NULL === $situation) {
return null;
}
return $this->translatableStringHelper->localize(
$this->configRepository->getProfessionalSituationsLabels()[$situation]
);
}
public function hasProfessionnalSituation()
{
return $this->configRepository->hasProfessionalSituation();
}
public function displayFamilialSituation($situation)
{
if (NULL === $situation) {
return null;
}
return $this->translatableStringHelper->localize(
$this->configRepository->getFamilialSituationsLabels()[$situation]
);
}
public function hasFamilialSituation()
{
return $this->configRepository->hasFamilialSituation();
}
public function hasProfessionnalSituation()
{
return $this->configRepository->hasProfessionalSituation();
}
}

View File

@@ -1,11 +1,29 @@
<?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\AMLI\FamilyMembersBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
* @coversNothing
*/
class FamilyMemberControllerTest extends WebTestCase
{
public function testEdit()
{
$client = static::createClient();
$crawler = $client->request('GET', '/edit');
}
public function testIndex()
{
$client = static::createClient();
@@ -19,12 +37,4 @@ class FamilyMemberControllerTest extends WebTestCase
$crawler = $client->request('GET', '/new');
}
public function testEdit()
{
$client = static::createClient();
$crawler = $client->request('GET', '/edit');
}
}