Merge remote-tracking branch 'origin/master' into refactor-using-rector-202303

This commit is contained in:
2023-04-15 00:07:09 +02:00
143 changed files with 3395 additions and 1300 deletions

View File

@@ -11,6 +11,8 @@ 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;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
@@ -20,6 +22,7 @@ use Chill\PersonBundle\Form\PersonType;
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;
@@ -44,6 +47,8 @@ use function is_array;
final class PersonController extends AbstractController
{
private AuthorizationHelperInterface $authorizationHelper;
/**
* @var ConfigPersonAltNamesHelper
*/
@@ -59,8 +64,6 @@ final class PersonController extends AbstractController
*/
protected $personRepository;
private Security $security;
/**
* @var SimilarPersonMatcher
*/
@@ -87,6 +90,7 @@ final class PersonController extends AbstractController
private $validator;
public function __construct(
AuthorizationHelperInterface $authorizationHelper,
SimilarPersonMatcher $similarPersonMatcher,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
@@ -95,8 +99,8 @@ final class PersonController extends AbstractController
LoggerInterface $logger,
ValidatorInterface $validator,
EntityManagerInterface $em,
Security $security
) {
$this->authorizationHelper = $authorizationHelper;
$this->similarPersonMatcher = $similarPersonMatcher;
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
@@ -105,7 +109,6 @@ final class PersonController extends AbstractController
$this->logger = $logger;
$this->validator = $validator;
$this->em = $em;
$this->security = $security;
}
public function editAction($person_id, Request $request)
@@ -206,22 +209,15 @@ 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".
*
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function newAction(Request $request)
public function newAction(Request $request): Response
{
$person = new Person();
if (
1 === count($this->security->getUser()
->getGroupCenters())
) {
$person->setCenter(
$this->security->getUser()
->getGroupCenters()[0]
->getCenter()
);
$authorizedCenters =$this->authorizationHelper->getReachableCenters($this->getUser(), PersonVoter::CREATE);
if (1 === count($authorizedCenters)) {
$person->setCenter($authorizedCenters[0]);
}
$form = $this->createForm(CreationPersonType::class, $person)