mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix syntax php7
This commit is contained in:
parent
0a17011cc3
commit
ea4e3c715e
@ -33,6 +33,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
|
||||
/**
|
||||
* Class AccompanyingPeriodController
|
||||
@ -56,12 +57,8 @@ class AccompanyingPeriodController extends AbstractController
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function listAction(int $person_id)
|
||||
public function listAction(int $person_id): Response
|
||||
{
|
||||
|
||||
$person = $this->_getPerson($person_id);
|
||||
|
||||
$event = new PrivacyEvent($person, [
|
||||
@ -76,12 +73,8 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||
*/
|
||||
public function createAction(int $person_id, Request $request)
|
||||
public function createAction(int $person_id, Request $request): Response
|
||||
{
|
||||
|
||||
$person = $this->_getPerson($person_id);
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
|
||||
@ -138,9 +131,10 @@ class AccompanyingPeriodController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateAction(int $person_id, int $period_id, Request $request){
|
||||
public function updateAction(int $person_id, int $period_id, Request $request): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
/** @var AccompanyingPeriod $accompanyingPeriod */
|
||||
@ -203,10 +197,9 @@ class AccompanyingPeriodController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function closeAction(int $person_id, Request $request)
|
||||
public function closeAction(int $person_id, Request $request): Response
|
||||
{
|
||||
|
||||
$person = $this->_getPerson($person_id);
|
||||
@ -287,10 +280,8 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\Validator\ConstraintViolationListInterface
|
||||
*/
|
||||
private function _validatePerson(Person $person) {
|
||||
private function _validatePerson(Person $person): ConstraintViolationListInterface
|
||||
{
|
||||
$errors = $this->get('validator')->validate($person, null,
|
||||
['Default']);
|
||||
$errors_accompanying_period = $this->get('validator')->validate($person, null,
|
||||
@ -303,10 +294,8 @@ class AccompanyingPeriodController extends AbstractController
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||
*/
|
||||
public function openAction($person_id, Request $request) {
|
||||
public function openAction(int $person_id, Request $request): Response
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
|
||||
@ -382,10 +371,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return object|\Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||
*/
|
||||
public function reOpenAction(int $person_id, int $period_id, Request $request)
|
||||
public function reOpenAction(int $person_id, int $period_id, Request $request): Response
|
||||
{
|
||||
/** @var Person $person */
|
||||
$person = $this->_getPerson($person_id);
|
||||
@ -432,7 +418,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the person is not found
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
private function _getPerson(int $id) : Person
|
||||
{
|
||||
|
@ -169,15 +169,15 @@ class AccompanyingPeriod
|
||||
*/
|
||||
public function isOpen(): bool
|
||||
{
|
||||
if ($this->getOpeningDate() > new \DateTime('now')) {
|
||||
if ($this->getOpeningDate() > new \DateTimeImmutable('now')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->getClosingDate() === null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,7 +210,7 @@ class AccompanyingPeriod
|
||||
/**
|
||||
* Set persons
|
||||
*/
|
||||
public function setPersons($persons) : AccompanyingPeriod
|
||||
public function setPersons($persons): AccompanyingPeriod
|
||||
{
|
||||
$this->persons = $persons;
|
||||
|
||||
@ -220,7 +220,7 @@ class AccompanyingPeriod
|
||||
/**
|
||||
* Get Persons
|
||||
*/
|
||||
public function getPersons() : Collection
|
||||
public function getPersons(): Collection
|
||||
{
|
||||
return $this->persons;
|
||||
}
|
||||
@ -228,7 +228,7 @@ class AccompanyingPeriod
|
||||
/**
|
||||
* Return true if a given Person is associated
|
||||
*/
|
||||
public function containsPerson(Person $person) : bool
|
||||
public function containsPerson(Person $person): bool
|
||||
{
|
||||
foreach ($this->persons as $p) {
|
||||
if ($p === $person) { return true; }
|
||||
@ -242,7 +242,7 @@ class AccompanyingPeriod
|
||||
* For consistency, you should use Person::addAccompanyingPeriod instead.
|
||||
* @see Person::addAccompanyingPeriod
|
||||
*/
|
||||
public function addPerson(Person $person = null) : AccompanyingPeriod
|
||||
public function addPerson(Person $person = null): AccompanyingPeriod
|
||||
{
|
||||
$this->persons[] = $person;
|
||||
|
||||
@ -252,7 +252,7 @@ class AccompanyingPeriod
|
||||
/**
|
||||
* Remove person.
|
||||
*/
|
||||
public function removePerson(Person $person) : void
|
||||
public function removePerson(Person $person): void
|
||||
{
|
||||
$this->persons->removeElement($person);
|
||||
}
|
||||
@ -281,25 +281,25 @@ class AccompanyingPeriod
|
||||
* This function test if the period is closed and if the period is the last
|
||||
* for the given person
|
||||
*/
|
||||
public function canBeReOpened(Person $person) : bool
|
||||
public function canBeReOpened(Person $person): bool
|
||||
{
|
||||
if ($this->isOpen() === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dump('parcours fermé: '. $this->getId());
|
||||
|
||||
foreach ($this->getPersons() as $p) {
|
||||
if ($p === $person) {
|
||||
$periods = $p->getAccompanyingPeriodsOrdered();
|
||||
return end($periods) === $this; // retourne TRUE si cette période est la dernière
|
||||
return end($periods) === $this;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function reOpen()
|
||||
public function reOpen(): void
|
||||
{
|
||||
$this->setClosingDate(null);
|
||||
$this->setClosingMotive(null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user