mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
fix deprecations: replace many strings by fqcn
This commit is contained in:
parent
2eb81ab3ec
commit
678386ffd6
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* Chill is a software for social workers
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016, Champs Libres Cooperative SCRLFS,
|
* Copyright (C) 2016, Champs Libres Cooperative SCRLFS,
|
||||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -23,6 +23,7 @@
|
|||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\MainBundle\Form\Type\AddressType;
|
use Chill\MainBundle\Form\Type\AddressType;
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
@ -37,97 +38,97 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
*/
|
*/
|
||||||
class PersonAddressController extends Controller
|
class PersonAddressController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function listAction($person_id)
|
public function listAction($person_id)
|
||||||
{
|
{
|
||||||
$person = $this->getDoctrine()->getManager()
|
$person = $this->getDoctrine()->getManager()
|
||||||
->getRepository('ChillPersonBundle:Person')
|
->getRepository('ChillPersonBundle:Person')
|
||||||
->find($person_id);
|
->find($person_id);
|
||||||
|
|
||||||
if ($person === null) {
|
if ($person === null) {
|
||||||
throw $this->createNotFoundException("Person with id $person_id not"
|
throw $this->createNotFoundException("Person with id $person_id not"
|
||||||
. " found ");
|
. " found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
$this->denyAccessUnlessGranted(
|
||||||
'CHILL_PERSON_SEE',
|
'CHILL_PERSON_SEE',
|
||||||
$person,
|
$person,
|
||||||
"You are not allowed to edit this person."
|
"You are not allowed to edit this person."
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:Address:list.html.twig', array(
|
return $this->render('ChillPersonBundle:Address:list.html.twig', array(
|
||||||
'person' => $person
|
'person' => $person
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newAction($person_id)
|
public function newAction($person_id)
|
||||||
{
|
{
|
||||||
$person = $this->getDoctrine()->getManager()
|
$person = $this->getDoctrine()->getManager()
|
||||||
->getRepository('ChillPersonBundle:Person')
|
->getRepository('ChillPersonBundle:Person')
|
||||||
->find($person_id);
|
->find($person_id);
|
||||||
|
|
||||||
if ($person === null) {
|
if ($person === null) {
|
||||||
throw $this->createNotFoundException("Person with id $person_id not"
|
throw $this->createNotFoundException("Person with id $person_id not"
|
||||||
. " found ");
|
. " found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
$this->denyAccessUnlessGranted(
|
||||||
'CHILL_PERSON_UPDATE',
|
'CHILL_PERSON_UPDATE',
|
||||||
$person,
|
$person,
|
||||||
"You are not allowed to edit this person."
|
"You are not allowed to edit this person."
|
||||||
);
|
);
|
||||||
|
|
||||||
$address = new Address();
|
$address = new Address();
|
||||||
|
|
||||||
$form = $this->createCreateForm($person, $address);
|
$form = $this->createCreateForm($person, $address);
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:Address:new.html.twig', array(
|
return $this->render('ChillPersonBundle:Address:new.html.twig', array(
|
||||||
'person' => $person,
|
'person' => $person,
|
||||||
'form' => $form->createView()
|
'form' => $form->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createAction($person_id, Request $request)
|
public function createAction($person_id, Request $request)
|
||||||
{
|
{
|
||||||
$person = $this->getDoctrine()->getManager()
|
$person = $this->getDoctrine()->getManager()
|
||||||
->getRepository('ChillPersonBundle:Person')
|
->getRepository('ChillPersonBundle:Person')
|
||||||
->find($person_id);
|
->find($person_id);
|
||||||
|
|
||||||
if ($person === null) {
|
if ($person === null) {
|
||||||
throw $this->createNotFoundException("Person with id $person_id not"
|
throw $this->createNotFoundException("Person with id $person_id not"
|
||||||
. " found ");
|
. " found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
$this->denyAccessUnlessGranted(
|
||||||
'CHILL_PERSON_UPDATE',
|
'CHILL_PERSON_UPDATE',
|
||||||
$person,
|
$person,
|
||||||
"You are not allowed to edit this person."
|
"You are not allowed to edit this person."
|
||||||
);
|
);
|
||||||
|
|
||||||
$address = new Address();
|
$address = new Address();
|
||||||
|
|
||||||
$form = $this->createCreateForm($person, $address);
|
$form = $this->createCreateForm($person, $address);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
$person->addAddress($address);
|
$person->addAddress($address);
|
||||||
|
|
||||||
if ($form->isSubmitted()) {
|
if ($form->isSubmitted()) {
|
||||||
$validatePersonErrors = $this->validatePerson($person);
|
$validatePersonErrors = $this->validatePerson($person);
|
||||||
|
|
||||||
if (count($validatePersonErrors) !== 0) {
|
if (count($validatePersonErrors) !== 0) {
|
||||||
foreach ($validatePersonErrors as $error) {
|
foreach ($validatePersonErrors as $error) {
|
||||||
$this->addFlash('error', $error->getMessage());
|
$this->addFlash('error', $error->getMessage());
|
||||||
}
|
}
|
||||||
} elseif ($form->isValid()) {
|
} elseif ($form->isValid()) {
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->addFlash(
|
$this->addFlash(
|
||||||
'success',
|
'success',
|
||||||
$this->get('translator')->trans('The new address was created successfully')
|
$this->get('translator')->trans('The new address was created successfully')
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_address_list', array(
|
return $this->redirectToRoute('chill_person_address_list', array(
|
||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
));
|
));
|
||||||
@ -136,66 +137,66 @@ class PersonAddressController extends Controller
|
|||||||
->trans('Error! Address not created!'));
|
->trans('Error! Address not created!'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:Address:new.html.twig', array(
|
return $this->render('ChillPersonBundle:Address:new.html.twig', array(
|
||||||
'person' => $person,
|
'person' => $person,
|
||||||
'form' => $form->createView()
|
'form' => $form->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editAction($person_id, $address_id)
|
public function editAction($person_id, $address_id)
|
||||||
{
|
{
|
||||||
$person = $this->getDoctrine()->getManager()
|
$person = $this->getDoctrine()->getManager()
|
||||||
->getRepository('ChillPersonBundle:Person')
|
->getRepository('ChillPersonBundle:Person')
|
||||||
->find($person_id);
|
->find($person_id);
|
||||||
|
|
||||||
if ($person === null) {
|
if ($person === null) {
|
||||||
throw $this->createNotFoundException("Person with id $person_id not"
|
throw $this->createNotFoundException("Person with id $person_id not"
|
||||||
. " found ");
|
. " found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
$this->denyAccessUnlessGranted(
|
||||||
'CHILL_PERSON_UPDATE',
|
'CHILL_PERSON_UPDATE',
|
||||||
$person,
|
$person,
|
||||||
"You are not allowed to edit this person."
|
"You are not allowed to edit this person."
|
||||||
);
|
);
|
||||||
|
|
||||||
$address = $this->findAddressById($person, $address_id);
|
$address = $this->findAddressById($person, $address_id);
|
||||||
|
|
||||||
$form = $this->createEditForm($person, $address);
|
$form = $this->createEditForm($person, $address);
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:Address:edit.html.twig', array(
|
return $this->render('ChillPersonBundle:Address:edit.html.twig', array(
|
||||||
'person' => $person,
|
'person' => $person,
|
||||||
'address' => $address,
|
'address' => $address,
|
||||||
'form' => $form->createView()
|
'form' => $form->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateAction($person_id, $address_id, Request $request)
|
public function updateAction($person_id, $address_id, Request $request)
|
||||||
{
|
{
|
||||||
$person = $this->getDoctrine()->getManager()
|
$person = $this->getDoctrine()->getManager()
|
||||||
->getRepository('ChillPersonBundle:Person')
|
->getRepository('ChillPersonBundle:Person')
|
||||||
->find($person_id);
|
->find($person_id);
|
||||||
|
|
||||||
if ($person === null) {
|
if ($person === null) {
|
||||||
throw $this->createNotFoundException("Person with id $person_id not"
|
throw $this->createNotFoundException("Person with id $person_id not"
|
||||||
. " found ");
|
. " found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
$this->denyAccessUnlessGranted(
|
||||||
'CHILL_PERSON_UPDATE',
|
'CHILL_PERSON_UPDATE',
|
||||||
$person,
|
$person,
|
||||||
"You are not allowed to edit this person."
|
"You are not allowed to edit this person."
|
||||||
);
|
);
|
||||||
|
|
||||||
$address = $this->findAddressById($person, $address_id);
|
$address = $this->findAddressById($person, $address_id);
|
||||||
|
|
||||||
$form = $this->createEditForm($person, $address);
|
$form = $this->createEditForm($person, $address);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
if ($request->getMethod() === 'POST') {
|
||||||
$validatePersonErrors = $this->validatePerson($person);
|
$validatePersonErrors = $this->validatePerson($person);
|
||||||
|
|
||||||
if (count($validatePersonErrors) !== 0) {
|
if (count($validatePersonErrors) !== 0) {
|
||||||
foreach ($validatePersonErrors as $error) {
|
foreach ($validatePersonErrors as $error) {
|
||||||
$this->addFlash('error', $error->getMessage());
|
$this->addFlash('error', $error->getMessage());
|
||||||
@ -203,11 +204,11 @@ class PersonAddressController extends Controller
|
|||||||
} elseif ($form->isValid()) {
|
} elseif ($form->isValid()) {
|
||||||
$this->getDoctrine()->getManager()
|
$this->getDoctrine()->getManager()
|
||||||
->flush();
|
->flush();
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')->trans(
|
$this->addFlash('success', $this->get('translator')->trans(
|
||||||
"The address has been successfully updated"
|
"The address has been successfully updated"
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_address_list', array(
|
return $this->redirectToRoute('chill_person_address_list', array(
|
||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
));
|
));
|
||||||
@ -216,14 +217,14 @@ class PersonAddressController extends Controller
|
|||||||
->trans('Error when updating the period'));
|
->trans('Error when updating the period'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:Address:edit.html.twig', array(
|
return $this->render('ChillPersonBundle:Address:edit.html.twig', array(
|
||||||
'person' => $person,
|
'person' => $person,
|
||||||
'address' => $address,
|
'address' => $address,
|
||||||
'form' => $form->createView()
|
'form' => $form->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Person $person
|
* @param Person $person
|
||||||
* @param Address $address
|
* @param Address $address
|
||||||
@ -238,16 +239,16 @@ class PersonAddressController extends Controller
|
|||||||
'address_id' => $address->getId()
|
'address_id' => $address->getId()
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array(
|
$form->add('submit', SubmitType::class, array(
|
||||||
'label' => 'Submit'
|
'label' => 'Submit'
|
||||||
));
|
));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Person $person
|
* @param Person $person
|
||||||
* @param Address $address
|
* @param Address $address
|
||||||
* @return \Symfony\Component\Form\Form
|
* @return \Symfony\Component\Form\Form
|
||||||
@ -260,16 +261,16 @@ class PersonAddressController extends Controller
|
|||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array(
|
$form->add('submit', SubmitType::class, array(
|
||||||
'label' => 'Submit'
|
'label' => 'Submit'
|
||||||
));
|
));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Person $person
|
* @param Person $person
|
||||||
* @param int $address_id
|
* @param int $address_id
|
||||||
* @return Address
|
* @return Address
|
||||||
@ -282,15 +283,15 @@ class PersonAddressController extends Controller
|
|||||||
->where(Criteria::expr()->eq('id', $address_id))
|
->where(Criteria::expr()->eq('id', $address_id))
|
||||||
->setMaxResults(1);
|
->setMaxResults(1);
|
||||||
$addresses = $person->getAddresses()->matching($criteria);
|
$addresses = $person->getAddresses()->matching($criteria);
|
||||||
|
|
||||||
if (count($addresses) === 0) {
|
if (count($addresses) === 0) {
|
||||||
throw $this->createNotFoundException("Address with id $address_id "
|
throw $this->createNotFoundException("Address with id $address_id "
|
||||||
. "matching person $person_id not found ");
|
. "matching person $person_id not found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $addresses->first();
|
return $addresses->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Chill\PersonBundle\Entity\Person $person
|
* @param Chill\PersonBundle\Entity\Person $person
|
||||||
* @return \Symfony\Component\Validator\ConstraintViolationListInterface
|
* @return \Symfony\Component\Validator\ConstraintViolationListInterface
|
||||||
@ -301,11 +302,11 @@ class PersonAddressController extends Controller
|
|||||||
->validate($person, array('Default'));
|
->validate($person, array('Default'));
|
||||||
$errors_addresses_consistent = $this->get('validator')
|
$errors_addresses_consistent = $this->get('validator')
|
||||||
->validate($person, array('addresses_consistent'));
|
->validate($person, array('addresses_consistent'));
|
||||||
|
|
||||||
foreach($errors_addresses_consistent as $error) {
|
foreach($errors_addresses_consistent as $error) {
|
||||||
$errors->add($error);
|
$errors->add($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,15 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class CountryOfBirthAggregator implements AggregatorInterface,
|
class CountryOfBirthAggregator implements AggregatorInterface,
|
||||||
ExportElementValidatedInterface
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -45,19 +46,19 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $countriesRepository;
|
protected $countriesRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $translatableStringHelper;
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
public function __construct(EntityRepository $countriesRepository,
|
public function __construct(EntityRepository $countriesRepository,
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
TranslatorInterface $translator)
|
TranslatorInterface $translator)
|
||||||
@ -66,16 +67,16 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
return 'person';
|
return 'person';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('group_by_level', 'choice', array(
|
$builder->add('group_by_level', ChoiceType::class, array(
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
'Group by continents' => 'continent',
|
'Group by continents' => 'continent',
|
||||||
'Group by country' => 'country'
|
'Group by country' => 'country'
|
||||||
@ -84,9 +85,9 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'multiple' => false
|
'multiple' => false
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
if ($data['group_by_level'] === null) {
|
if ($data['group_by_level'] === null) {
|
||||||
@ -94,7 +95,7 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// add a clause in select part
|
// add a clause in select part
|
||||||
@ -109,10 +110,10 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
. 'WHEN countryOfBirth.countryCode IN(:cob_south_america_codes) THEN \'SA\' '
|
. 'WHEN countryOfBirth.countryCode IN(:cob_south_america_codes) THEN \'SA\' '
|
||||||
. 'WHEN countryOfBirth.countryCode IN(:cob_oceania_codes) THEN \'OC\' '
|
. 'WHEN countryOfBirth.countryCode IN(:cob_oceania_codes) THEN \'OC\' '
|
||||||
. 'WHEN countryOfBirth.countryCode IN(:cob_antartica_codes) THEN \'AN\' '
|
. 'WHEN countryOfBirth.countryCode IN(:cob_antartica_codes) THEN \'AN\' '
|
||||||
. 'ELSE \'\' '
|
. 'ELSE \'\' '
|
||||||
. 'END as country_of_birth_aggregator ';
|
. 'END as country_of_birth_aggregator ';
|
||||||
$qb->addSelect($clause);
|
$qb->addSelect($clause);
|
||||||
$params =
|
$params =
|
||||||
array(
|
array(
|
||||||
'cob_africa_codes' => CountriesInfo::getCountriesCodeByContinent('AF'),
|
'cob_africa_codes' => CountriesInfo::getCountriesCodeByContinent('AF'),
|
||||||
'cob_asia_codes' => CountriesInfo::getCountriesCodeByContinent('AS'),
|
'cob_asia_codes' => CountriesInfo::getCountriesCodeByContinent('AS'),
|
||||||
@ -129,47 +130,47 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
throw new \LogicException("The group_by_level '".$data['group_by_level']
|
throw new \LogicException("The group_by_level '".$data['group_by_level']
|
||||||
." is not known.");
|
." is not known.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$qb->leftJoin('person.countryOfBirth', 'countryOfBirth');
|
$qb->leftJoin('person.countryOfBirth', 'countryOfBirth');
|
||||||
|
|
||||||
// add group by
|
// add group by
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
if (!empty($groupBy)) {
|
||||||
$qb->addGroupBy('country_of_birth_aggregator');
|
$qb->addGroupBy('country_of_birth_aggregator');
|
||||||
} else {
|
} else {
|
||||||
$qb->groupBy('country_of_birth_aggregator');
|
$qb->groupBy('country_of_birth_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return "Group people by country of birth";
|
return "Group people by country of birth";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
public function getQueryKeys($data)
|
||||||
{
|
{
|
||||||
return array('country_of_birth_aggregator');
|
return array('country_of_birth_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ($data['group_by_level'] === 'country') {
|
if ($data['group_by_level'] === 'country') {
|
||||||
$qb = $this->countriesRepository->createQueryBuilder('c');
|
$qb = $this->countriesRepository->createQueryBuilder('c');
|
||||||
|
|
||||||
$countries = $qb
|
$countries = $qb
|
||||||
->andWhere($qb->expr()->in('c.countryCode', ':countries'))
|
->andWhere($qb->expr()->in('c.countryCode', ':countries'))
|
||||||
->setParameter('countries', $values)
|
->setParameter('countries', $values)
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR);
|
->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR);
|
||||||
|
|
||||||
// initialize array and add blank key for null values
|
// initialize array and add blank key for null values
|
||||||
$labels[''] = $this->translator->trans('without data');
|
$labels[''] = $this->translator->trans('without data');
|
||||||
$labels['_header'] = $this->translator->trans('Country of birth');
|
$labels['_header'] = $this->translator->trans('Country of birth');
|
||||||
@ -177,9 +178,9 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
$labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']);
|
$labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} elseif ($data['group_by_level'] === 'continent') {
|
} elseif ($data['group_by_level'] === 'continent') {
|
||||||
|
|
||||||
$labels = array(
|
$labels = array(
|
||||||
'EU' => $this->translator->trans('Europe'),
|
'EU' => $this->translator->trans('Europe'),
|
||||||
'AS' => $this->translator->trans('Asia'),
|
'AS' => $this->translator->trans('Asia'),
|
||||||
@ -192,11 +193,11 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
|||||||
'_header' => $this->translator->trans('Continent of birth')
|
'_header' => $this->translator->trans('Continent of birth')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return function($value) use ($labels) {
|
return function($value) use ($labels) {
|
||||||
return $labels[$value];
|
return $labels[$value];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,10 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
@ -44,19 +45,19 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $countriesRepository;
|
protected $countriesRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $translatableStringHelper;
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
public function __construct(EntityRepository $countriesRepository,
|
public function __construct(EntityRepository $countriesRepository,
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
TranslatorInterface $translator)
|
TranslatorInterface $translator)
|
||||||
@ -65,16 +66,16 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
return 'person';
|
return 'person';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('group_by_level', 'choice', array(
|
$builder->add('group_by_level', ChoiceType::class, array(
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
'Group by continents' => 'continent',
|
'Group by continents' => 'continent',
|
||||||
'Group by country' => 'country'
|
'Group by country' => 'country'
|
||||||
@ -83,7 +84,7 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'multiple' => false
|
'multiple' => false
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
@ -93,7 +94,7 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// add a clause in select part
|
// add a clause in select part
|
||||||
@ -108,10 +109,10 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
. 'WHEN nationality.countryCode IN(:south_america_codes) THEN \'SA\' '
|
. 'WHEN nationality.countryCode IN(:south_america_codes) THEN \'SA\' '
|
||||||
. 'WHEN nationality.countryCode IN(:oceania_codes) THEN \'OC\' '
|
. 'WHEN nationality.countryCode IN(:oceania_codes) THEN \'OC\' '
|
||||||
. 'WHEN nationality.countryCode IN(:antartica_codes) THEN \'AN\' '
|
. 'WHEN nationality.countryCode IN(:antartica_codes) THEN \'AN\' '
|
||||||
. 'ELSE \'\' '
|
. 'ELSE \'\' '
|
||||||
. 'END as nationality_aggregator ';
|
. 'END as nationality_aggregator ';
|
||||||
$qb->addSelect($clause);
|
$qb->addSelect($clause);
|
||||||
$params =
|
$params =
|
||||||
array(
|
array(
|
||||||
'africa_codes' => CountriesInfo::getCountriesCodeByContinent('AF'),
|
'africa_codes' => CountriesInfo::getCountriesCodeByContinent('AF'),
|
||||||
'asia_codes' => CountriesInfo::getCountriesCodeByContinent('AS'),
|
'asia_codes' => CountriesInfo::getCountriesCodeByContinent('AS'),
|
||||||
@ -128,47 +129,47 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
throw new \LogicException("The group_by_level '".$data['group_by_level']
|
throw new \LogicException("The group_by_level '".$data['group_by_level']
|
||||||
." is not known.");
|
." is not known.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$qb->leftJoin('person.nationality', 'nationality');
|
$qb->leftJoin('person.nationality', 'nationality');
|
||||||
|
|
||||||
// add group by
|
// add group by
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
if (!empty($groupBy)) {
|
||||||
$qb->addGroupBy('nationality_aggregator');
|
$qb->addGroupBy('nationality_aggregator');
|
||||||
} else {
|
} else {
|
||||||
$qb->groupBy('nationality_aggregator');
|
$qb->groupBy('nationality_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return "Group people by nationality";
|
return "Group people by nationality";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
public function getQueryKeys($data)
|
||||||
{
|
{
|
||||||
return array('nationality_aggregator');
|
return array('nationality_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ($data['group_by_level'] === 'country') {
|
if ($data['group_by_level'] === 'country') {
|
||||||
$qb = $this->countriesRepository->createQueryBuilder('c');
|
$qb = $this->countriesRepository->createQueryBuilder('c');
|
||||||
|
|
||||||
$countries = $qb
|
$countries = $qb
|
||||||
->andWhere($qb->expr()->in('c.countryCode', ':countries'))
|
->andWhere($qb->expr()->in('c.countryCode', ':countries'))
|
||||||
->setParameter('countries', $values)
|
->setParameter('countries', $values)
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR);
|
->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR);
|
||||||
|
|
||||||
// initialize array and add blank key for null values
|
// initialize array and add blank key for null values
|
||||||
$labels[''] = $this->translator->trans('without data');
|
$labels[''] = $this->translator->trans('without data');
|
||||||
$labels['_header'] = $this->translator->trans('Nationality');
|
$labels['_header'] = $this->translator->trans('Nationality');
|
||||||
@ -176,9 +177,9 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
$labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']);
|
$labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} elseif ($data['group_by_level'] === 'continent') {
|
} elseif ($data['group_by_level'] === 'continent') {
|
||||||
|
|
||||||
$labels = array(
|
$labels = array(
|
||||||
'EU' => $this->translator->trans('Europe'),
|
'EU' => $this->translator->trans('Europe'),
|
||||||
'AS' => $this->translator->trans('Asia'),
|
'AS' => $this->translator->trans('Asia'),
|
||||||
@ -191,11 +192,11 @@ class NationalityAggregator implements AggregatorInterface,
|
|||||||
'_header' => $this->translator->trans('Continent')
|
'_header' => $this->translator->trans('Continent')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return function($value) use ($labels) {
|
return function($value) use ($labels) {
|
||||||
return $labels[$value];
|
return $labels[$value];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,27 +27,28 @@ use Doctrine\ORM\Query\Expr;
|
|||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class GenderFilter implements FilterInterface,
|
class GenderFilter implements FilterInterface,
|
||||||
ExportElementValidatedInterface
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
return 'person';
|
return 'person';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('accepted_genders', 'choice', array(
|
$builder->add('accepted_genders', ChoiceType::class, array(
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
Person::FEMALE_GENDER => 'Woman',
|
Person::FEMALE_GENDER => 'Woman',
|
||||||
Person::MALE_GENDER => 'Man'
|
Person::MALE_GENDER => 'Man'
|
||||||
@ -56,7 +57,7 @@ class GenderFilter implements FilterInterface,
|
|||||||
'expanded' => false
|
'expanded' => false
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
if (count($data['accepted_genders']) === 0) {
|
if (count($data['accepted_genders']) === 0) {
|
||||||
@ -64,38 +65,38 @@ class GenderFilter implements FilterInterface,
|
|||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('person.gender', ':person_gender');
|
$clause = $qb->expr()->in('person.gender', ':person_gender');
|
||||||
|
|
||||||
|
|
||||||
if ($where instanceof Expr\Andx) {
|
if ($where instanceof Expr\Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
} else {
|
} else {
|
||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
$qb->setParameter('person_gender', $data['accepted_genders']);
|
$qb->setParameter('person_gender', $data['accepted_genders']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A title which will be used in the label for the form
|
* A title which will be used in the label for the form
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return 'Filter by person gender';
|
return 'Filter by person gender';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
public function describeAction($data, $format = 'string')
|
||||||
{
|
{
|
||||||
switch($data['accepted_genders']) {
|
switch($data['accepted_genders']) {
|
||||||
|
@ -9,6 +9,7 @@ use Symfony\Component\Form\FormEvents;
|
|||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
|
|
||||||
class AccompanyingPeriodType extends AbstractType
|
class AccompanyingPeriodType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -22,13 +23,13 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
if ($options['period_action'] !== 'close') {
|
if ($options['period_action'] !== 'close') {
|
||||||
$builder
|
$builder
|
||||||
->add('openingDate', 'date', array(
|
->add('openingDate', 'date', array(
|
||||||
"required" => true,
|
"required" => true,
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'format' => 'dd-MM-yyyy'
|
'format' => 'dd-MM-yyyy'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// the closingDate should be seen only if period_action = close
|
// the closingDate should be seen only if period_action = close
|
||||||
// or period_action = update AND accopanying period is already closed
|
// or period_action = update AND accopanying period is already closed
|
||||||
$builder->addEventListener(
|
$builder->addEventListener(
|
||||||
FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
||||||
@ -49,13 +50,13 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
$form->add('closingMotive', 'closing_motive');
|
$form->add('closingMotive', 'closing_motive');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$builder->add('remark', 'textarea', array(
|
$builder->add('remark', TextareaType::class, array(
|
||||||
'required' => false
|
'required' => false
|
||||||
))
|
))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param OptionsResolverInterface $resolver
|
* @param OptionsResolverInterface $resolver
|
||||||
*/
|
*/
|
||||||
@ -71,7 +72,7 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
->addAllowedValues(array('period_action' => array(
|
->addAllowedValues(array('period_action' => array(
|
||||||
'update', 'open', 'close', 'create')));
|
'update', 'open', 'close', 'create')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
{
|
{
|
||||||
$view->vars['action'] = $options['period_action'];
|
$view->vars['action'] = $options['period_action'];
|
||||||
|
@ -24,29 +24,31 @@ namespace Chill\PersonBundle\Form;
|
|||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Chill\PersonBundle\Form\Type\GenderType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Form\Type\GenderType;
|
||||||
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
||||||
|
|
||||||
class CreationPersonType extends AbstractType
|
class CreationPersonType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
||||||
const NAME = 'chill_personbundle_person_creation';
|
const NAME = 'chill_personbundle_person_creation';
|
||||||
|
|
||||||
const FORM_NOT_REVIEWED = 'not_reviewed';
|
const FORM_NOT_REVIEWED = 'not_reviewed';
|
||||||
const FORM_REVIEWED = 'reviewed' ;
|
const FORM_REVIEWED = 'reviewed' ;
|
||||||
const FORM_BEING_REVIEWED = 'being_reviewed';
|
const FORM_BEING_REVIEWED = 'being_reviewed';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var CenterTransformer
|
* @var CenterTransformer
|
||||||
*/
|
*/
|
||||||
private $centerTransformer;
|
private $centerTransformer;
|
||||||
|
|
||||||
public function __construct(CenterTransformer $centerTransformer) {
|
public function __construct(CenterTransformer $centerTransformer) {
|
||||||
$this->centerTransformer = $centerTransformer;
|
$this->centerTransformer = $centerTransformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FormBuilderInterface $builder
|
* @param FormBuilderInterface $builder
|
||||||
* @param array $options
|
* @param array $options
|
||||||
@ -54,24 +56,24 @@ class CreationPersonType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
if ($options['form_status'] === self::FORM_BEING_REVIEWED) {
|
if ($options['form_status'] === self::FORM_BEING_REVIEWED) {
|
||||||
|
|
||||||
$dateToStringTransformer = new DateTimeToStringTransformer(
|
$dateToStringTransformer = new DateTimeToStringTransformer(
|
||||||
null, null, 'd-m-Y', false);
|
null, null, 'd-m-Y', false);
|
||||||
|
|
||||||
$builder->add('firstName', 'hidden')
|
$builder->add('firstName', HiddenType::class)
|
||||||
->add('lastName', 'hidden')
|
->add('lastName', HiddenType::class)
|
||||||
->add('birthdate', 'hidden', array(
|
->add('birthdate', HiddenType::class, array(
|
||||||
'property_path' => 'birthdate'
|
'property_path' => 'birthdate'
|
||||||
))
|
))
|
||||||
->add('gender', 'hidden')
|
->add('gender', HiddenType::class)
|
||||||
->add('creation_date', 'hidden', array(
|
->add('creation_date', HiddenType::class, array(
|
||||||
'mapped' => false
|
'mapped' => false
|
||||||
))
|
))
|
||||||
->add('form_status', 'hidden', array(
|
->add('form_status', HiddenType::class, array(
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
'data' => $options['form_status']
|
'data' => $options['form_status']
|
||||||
))
|
))
|
||||||
->add('center', 'hidden')
|
->add('center', HiddenType::class)
|
||||||
;
|
;
|
||||||
$builder->get('birthdate')
|
$builder->get('birthdate')
|
||||||
->addModelTransformer($dateToStringTransformer);
|
->addModelTransformer($dateToStringTransformer);
|
||||||
@ -83,18 +85,18 @@ class CreationPersonType extends AbstractType
|
|||||||
$builder
|
$builder
|
||||||
->add('firstName')
|
->add('firstName')
|
||||||
->add('lastName')
|
->add('lastName')
|
||||||
->add('birthdate', 'date', array('required' => false,
|
->add('birthdate', 'date', array('required' => false,
|
||||||
'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
|
'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
|
||||||
->add('gender', new GenderType(), array(
|
->add('gender', new GenderType(), array(
|
||||||
'required' => true, 'empty_value' => null
|
'required' => true, 'empty_value' => null
|
||||||
))
|
))
|
||||||
->add('creation_date', 'date', array(
|
->add('creation_date', 'date', array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'format' => 'dd-MM-yyyy',
|
'format' => 'dd-MM-yyyy',
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
'data' => new \DateTime()))
|
'data' => new \DateTime()))
|
||||||
->add('form_status', 'hidden', array(
|
->add('form_status', HiddenType::class, array(
|
||||||
'data' => $options['form_status'],
|
'data' => $options['form_status'],
|
||||||
'mapped' => false
|
'mapped' => false
|
||||||
))
|
))
|
||||||
@ -102,7 +104,7 @@ class CreationPersonType extends AbstractType
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param OptionsResolver $resolver
|
* @param OptionsResolver $resolver
|
||||||
*/
|
*/
|
||||||
@ -111,7 +113,7 @@ class CreationPersonType extends AbstractType
|
|||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'Chill\PersonBundle\Entity\Person'
|
'data_class' => 'Chill\PersonBundle\Entity\Person'
|
||||||
));
|
));
|
||||||
|
|
||||||
$resolver->setRequired('form_status')
|
$resolver->setRequired('form_status')
|
||||||
->setAllowedValues('form_status', array(
|
->setAllowedValues('form_status', array(
|
||||||
self::FORM_BEING_REVIEWED,
|
self::FORM_BEING_REVIEWED,
|
||||||
|
@ -25,10 +25,12 @@ use Symfony\Component\Form\AbstractType;
|
|||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
|
||||||
use Chill\PersonBundle\Form\Type\GenderType;
|
use Chill\PersonBundle\Form\Type\GenderType;
|
||||||
use Chill\MainBundle\Form\Type\Select2CountryType;
|
use Chill\MainBundle\Form\Type\Select2CountryType;
|
||||||
use Chill\MainBundle\Form\Type\Select2LanguageType;
|
use Chill\MainBundle\Form\Type\Select2LanguageType;
|
||||||
|
use Chill\CustomFieldsBundle\Form\Type\CustomFieldType;
|
||||||
|
|
||||||
class PersonType extends AbstractType
|
class PersonType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -68,7 +70,7 @@ class PersonType extends AbstractType
|
|||||||
;
|
;
|
||||||
|
|
||||||
if ($this->config['place_of_birth'] === 'visible') {
|
if ($this->config['place_of_birth'] === 'visible') {
|
||||||
$builder->add('placeOfBirth', 'text', array('required' => false));
|
$builder->add('placeOfBirth', TextType::class, array('required' => false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config['phonenumber'] === 'visible') {
|
if ($this->config['phonenumber'] === 'visible') {
|
||||||
@ -106,7 +108,7 @@ class PersonType extends AbstractType
|
|||||||
|
|
||||||
if($options['cFGroup']) {
|
if($options['cFGroup']) {
|
||||||
$builder
|
$builder
|
||||||
->add('cFData', 'custom_field',
|
->add('cFData', CustomFieldType::class,
|
||||||
array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup']))
|
array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup']))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user