mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
@@ -23,9 +22,7 @@ use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Search\SimilarPersonMatcher;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
@@ -33,18 +30,11 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function count;
|
||||
use function hash;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
final class PersonController extends AbstractController
|
||||
{
|
||||
@@ -131,6 +121,7 @@ final class PersonController extends AbstractController
|
||||
* name="chill_person_household_person_history",
|
||||
* methods={"GET", "POST"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("person", options={"id": "person_id"})
|
||||
*/
|
||||
public function householdHistoryByPerson(Request $request, Person $person): Response
|
||||
@@ -160,6 +151,7 @@ final class PersonController extends AbstractController
|
||||
*
|
||||
* The next post compare the data with previous one and, if yes, show a
|
||||
* review page if there are "alternate persons".
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/new", name="chill_person_new")
|
||||
*/
|
||||
public function newAction(Request $request): Response
|
||||
@@ -168,7 +160,7 @@ final class PersonController extends AbstractController
|
||||
|
||||
$authorizedCenters = $this->authorizationHelper->getReachableCenters($this->getUser(), PersonVoter::CREATE);
|
||||
|
||||
if (1 === count($authorizedCenters)) {
|
||||
if (1 === \count($authorizedCenters)) {
|
||||
$person->setCenter($authorizedCenters[0]);
|
||||
}
|
||||
|
||||
@@ -183,10 +175,10 @@ final class PersonController extends AbstractController
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_GET) {
|
||||
if (Request::METHOD_GET === $request->getMethod()) {
|
||||
$this->lastPostDataReset();
|
||||
} elseif (
|
||||
$request->getMethod() === Request::METHOD_POST
|
||||
Request::METHOD_POST === $request->getMethod()
|
||||
&& $form->isValid()
|
||||
) {
|
||||
$alternatePersons = $this->similarPersonMatcher
|
||||
@@ -194,7 +186,7 @@ final class PersonController extends AbstractController
|
||||
|
||||
if (
|
||||
false === $this->isLastPostDataChanges($form, $request, true)
|
||||
|| count($alternatePersons) === 0
|
||||
|| 0 === \count($alternatePersons)
|
||||
) {
|
||||
$this->em->persist($person);
|
||||
|
||||
@@ -209,7 +201,7 @@ final class PersonController extends AbstractController
|
||||
|
||||
$member = new HouseholdMember();
|
||||
$member->setPerson($person);
|
||||
$member->setStartDate(new DateTimeImmutable());
|
||||
$member->setStartDate(new \DateTimeImmutable());
|
||||
|
||||
$household->addMember($member);
|
||||
$household->setForceAddress($address);
|
||||
@@ -243,7 +235,7 @@ final class PersonController extends AbstractController
|
||||
['person_id' => $person->getId()]
|
||||
);
|
||||
}
|
||||
} elseif ($request->getMethod() === Request::METHOD_POST && !$form->isValid()) {
|
||||
} elseif (Request::METHOD_POST === $request->getMethod() && !$form->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans('This form contains errors'));
|
||||
}
|
||||
|
||||
@@ -264,8 +256,7 @@ final class PersonController extends AbstractController
|
||||
$person = $this->_getPerson($person_id);
|
||||
|
||||
if (null === $person) {
|
||||
throw $this->createNotFoundException("Person with id {$person_id} not"
|
||||
. ' found on this server');
|
||||
throw $this->createNotFoundException("Person with id {$person_id} not".' found on this server');
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted(
|
||||
@@ -290,7 +281,6 @@ final class PersonController extends AbstractController
|
||||
/**
|
||||
* easy getting a person by his id.
|
||||
*
|
||||
*
|
||||
* @return \Chill\PersonBundle\Entity\Person
|
||||
*/
|
||||
private function _getPerson(int $id)
|
||||
@@ -306,14 +296,14 @@ final class PersonController extends AbstractController
|
||||
$errors = $this->validator
|
||||
->validate($person, null, ['creation']);
|
||||
|
||||
//validate accompanying periods
|
||||
// validate accompanying periods
|
||||
$periods = $person->getAccompanyingPeriods();
|
||||
|
||||
foreach ($periods as $period) {
|
||||
$period_errors = $this->validator
|
||||
->validate($period);
|
||||
|
||||
//group errors :
|
||||
// group errors :
|
||||
foreach ($period_errors as $error) {
|
||||
$errors->add($error);
|
||||
}
|
||||
@@ -353,15 +343,15 @@ final class PersonController extends AbstractController
|
||||
$ignoredFields = ['form_status', '_token'];
|
||||
|
||||
foreach ($request->request->all()[$form->getName()] as $field => $value) {
|
||||
if (in_array($field, $ignoredFields, true)) {
|
||||
if (\in_array($field, $ignoredFields, true)) {
|
||||
continue;
|
||||
}
|
||||
$fields[$field] = is_array($value) ?
|
||||
implode(',', $value) : $value;
|
||||
$fields[$field] = \is_array($value) ?
|
||||
\implode(',', $value) : $value;
|
||||
}
|
||||
ksort($fields);
|
||||
|
||||
return hash('sha512', implode('&', $fields));
|
||||
return \hash('sha512', \implode('&', $fields));
|
||||
}
|
||||
|
||||
private function lastPostDataReset(): void
|
||||
|
Reference in New Issue
Block a user