mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 18:43:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -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\PersonBundle\Validator\Constraints\Household;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
@@ -13,6 +20,6 @@ class HouseholdMembershipSequential extends Constraint
|
||||
|
||||
public function getTargets()
|
||||
{
|
||||
return [ self::CLASS_CONSTRAINT ];
|
||||
return [self::CLASS_CONSTRAINT];
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,24 @@
|
||||
<?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\PersonBundle\Validator\Constraints\Household;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\MainBundle\Util\DateRangeCovering;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Validate that a person does not belong to two household at
|
||||
* the same time
|
||||
* Validate that a person does not belong to two household at
|
||||
* the same time.
|
||||
*/
|
||||
class HouseholdMembershipSequentialValidator extends ConstraintValidator
|
||||
{
|
||||
@@ -45,7 +51,7 @@ class HouseholdMembershipSequentialValidator extends ConstraintValidator
|
||||
$covers->compute();
|
||||
|
||||
if ($covers->hasIntersections()) {
|
||||
foreach ($covers->getIntersections() as list($start, $end, $metadata)) {
|
||||
foreach ($covers->getIntersections() as [$start, $end, $metadata]) {
|
||||
$participation = $participations[$metadata[0]];
|
||||
$nbHousehold = count($metadata);
|
||||
|
||||
@@ -53,15 +59,14 @@ class HouseholdMembershipSequentialValidator extends ConstraintValidator
|
||||
->buildViolation($constraint->message)
|
||||
->setParameters([
|
||||
'%person_name%' => $this->render->renderString(
|
||||
$participation->getPerson(), []
|
||||
$participation->getPerson(),
|
||||
[]
|
||||
),
|
||||
// TODO when date is correctly i18n, fix this
|
||||
'%from%' => $start->format('d-m-Y'),
|
||||
'%nbHousehold%' => $nbHousehold,
|
||||
|
||||
])
|
||||
->addViolation()
|
||||
;
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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\PersonBundle\Validator\Constraints\Household;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
@@ -10,6 +17,7 @@ use Symfony\Component\Validator\Constraint;
|
||||
class MaxHolder extends Constraint
|
||||
{
|
||||
public $message = 'household.max_holder_overflowed';
|
||||
|
||||
public $messageInfinity = 'household.max_holder_overflowed_infinity';
|
||||
|
||||
public function getTargets()
|
||||
|
@@ -1,12 +1,17 @@
|
||||
<?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\PersonBundle\Validator\Constraints\Household;
|
||||
|
||||
use Chill\MainBundle\Util\DateRangeCovering;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
class MaxHolderValidator extends ConstraintValidator
|
||||
{
|
||||
@@ -20,8 +25,10 @@ class MaxHolderValidator extends ConstraintValidator
|
||||
return;
|
||||
}
|
||||
|
||||
$covers = new DateRangeCovering(self::MAX_HOLDERS,
|
||||
$holders[0]->getStartDate()->getTimezone());
|
||||
$covers = new DateRangeCovering(
|
||||
self::MAX_HOLDERS,
|
||||
$holders[0]->getStartDate()->getTimezone()
|
||||
);
|
||||
|
||||
foreach ($holders as $key => $member) {
|
||||
$covers->add($member->getStartDate(), $member->getEndDate(), $key);
|
||||
@@ -30,18 +37,17 @@ class MaxHolderValidator extends ConstraintValidator
|
||||
$covers->compute();
|
||||
|
||||
if ($covers->hasIntersections()) {
|
||||
foreach ($covers->getIntersections() as list($start, $end, $ids)) {
|
||||
$msg = $end === null ? $constraint->messageInfinity :
|
||||
foreach ($covers->getIntersections() as [$start, $end, $ids]) {
|
||||
$msg = null === $end ? $constraint->messageInfinity :
|
||||
$constraint->message;
|
||||
|
||||
$this->context->buildViolation($msg)
|
||||
->setParameters([
|
||||
'{{ start }}' => $start->format('d-m-Y'), // TODO fix when MessageParameter works with timezone
|
||||
'{{ end }}' => $end === null ? null : $end->format('d-m-Y')
|
||||
'{{ end }}' => null === $end ? null : $end->format('d-m-Y'),
|
||||
])
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user