apply rector rules: symfony **UP TO** 44

This commit is contained in:
2023-07-28 01:52:53 +02:00
parent b6a094aeee
commit c20f65eebb
88 changed files with 211 additions and 320 deletions

View File

@@ -90,7 +90,7 @@ class ReportController extends AbstractController
$form = $this->createCreateForm($entity, $person, $cFGroup);
$form->handleRequest($request);
if ($form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$entity->setCFGroup($cFGroup);
$entity->setPerson($person);
@@ -107,10 +107,7 @@ class ReportController extends AbstractController
->trans('Success : report created!')
);
return $this->redirect($this->generateUrl(
'report_view',
['person_id' => $person_id, 'report_id' => $entity->getId()]
));
return $this->redirectToRoute('report_view', ['person_id' => $person_id, 'report_id' => $entity->getId()]);
}
$this->get('session')
@@ -166,7 +163,7 @@ class ReportController extends AbstractController
'element_id' => $report->getId(),
'action' => 'edit',
]);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
return $this->render('ChillReportBundle:Report:edit.html.twig', [
'edit_form' => $editForm->createView(),
@@ -247,7 +244,7 @@ class ReportController extends AbstractController
'element_class' => Report::class,
'action' => 'list',
]);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
return $this->render('ChillReportBundle:Report:list.html.twig', [
'reports' => $reports,
@@ -335,24 +332,14 @@ class ReportController extends AbstractController
$cFGroupId = $request->query->get('cFGroup');
if ($request->query->has('cFGroup')) {
return $this->redirect(
$this->generateUrl(
'report_new',
['person_id' => $person_id, 'cf_group_id' => $cFGroupId]
)
);
return $this->redirectToRoute('report_new', ['person_id' => $person_id, 'cf_group_id' => $cFGroupId]);
}
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
if (count($cFGroups) === 1) {
return $this->redirect(
$this->generateUrl(
'report_new',
['person_id' => $person_id, 'cf_group_id' => $cFGroups[0]->getId()]
)
);
return $this->redirectToRoute('report_new', ['person_id' => $person_id, 'cf_group_id' => $cFGroups[0]->getId()]);
}
$cFGroupsChoice = [];
@@ -392,12 +379,7 @@ class ReportController extends AbstractController
$cFGroupId = $request->query->get('cFGroup');
if ($request->query->has('cFGroup')) {
return $this->redirect(
$this->generateUrl(
'report_export_list',
['cf_group_id' => $cFGroupId]
)
);
return $this->redirectToRoute('report_export_list', ['cf_group_id' => $cFGroupId]);
}
$em = $this->getDoctrine()->getManager();
@@ -406,12 +388,7 @@ class ReportController extends AbstractController
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
if (count($cFGroups) === 1) {
return $this->redirect(
$this->generateUrl(
'report_export_list',
['cf_group_id' => $cFGroups[0]->getId()]
)
);
return $this->redirectToRoute('report_export_list', ['cf_group_id' => $cFGroups[0]->getId()]);
}
$cFGroupsChoice = [];
@@ -461,7 +438,7 @@ class ReportController extends AbstractController
$editForm = $this->createEditForm($report);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em->flush();
$this->get('session')
@@ -479,12 +456,9 @@ class ReportController extends AbstractController
'element_id' => $report->getId(),
'action' => 'update',
]);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
return $this->redirect($this->generateUrl(
'report_view',
['person_id' => $report->getPerson()->getId(), 'report_id' => $report_id]
));
return $this->redirectToRoute('report_view', ['person_id' => $report->getPerson()->getId(), 'report_id' => $report_id]);
}
$this->get('session')
@@ -530,7 +504,7 @@ class ReportController extends AbstractController
'element_id' => $entity->getId(),
'action' => 'view',
]);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
return $this->render('ChillReportBundle:Report:view.html.twig', [
'entity' => $entity,

View File

@@ -38,7 +38,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
*/
private $faker;
public function __construct()
public function __construct(private \Doctrine\ORM\EntityManager $entityManager)
{
$this->faker = FakerFactory::create('fr_FR');
}
@@ -61,7 +61,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
private function createExpected(ObjectManager $manager)
{
$charline = $this->container->get('doctrine.orm.entity_manager')
$charline = $this->entityManager
->getRepository(Person::class)
->findOneBy(['firstName' => 'Charline', 'lastName' => 'DEPARDIEU']);
@@ -147,7 +147,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
private function getPeopleRandom($percentage)
{
$people = $this->container->get('doctrine.orm.entity_manager')
$people = $this->entityManager
->getRepository(Person::class)
->findAll();

View File

@@ -174,7 +174,7 @@ final class ReportControllerNextTest extends WebTestCase
/**
* @return \Symfony\Component\DomCrawler\Form
*/
protected function getReportForm(Person $person, CustomFieldsGroup $group, Client $client)
protected function getReportForm(Person $person, CustomFieldsGroup $group, \Symfony\Component\BrowserKit\AbstractBrowser $client)
{
$url = sprintf(
'fr/person/%d/report/cfgroup/%d/new',

View File

@@ -417,7 +417,7 @@ final class ReportControllerTest extends WebTestCase
protected function getReportForm(
Person $person,
CustomFieldsGroup $group,
\Symfony\Component\BrowserKit\Client $client
\Symfony\Component\BrowserKit\AbstractBrowser $client
) {
$url = sprintf(
'fr/person/%d/report/cfgroup/%d/new',

View File

@@ -103,7 +103,7 @@ final class ReportSearchTest extends WebTestCase
}
/**
* @return \Symfony\Component\BrowserKit\Client
* @return \Symfony\Component\BrowserKit\AbstractBrowser
*/
private function getAuthenticatedClient(mixed $username = 'center a_social')
{

View File

@@ -1,7 +1,7 @@
services:
Chill\ReportBundle\Controller\ReportController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$paginator: '@Chill\MainBundle\Pagination\PaginatorFactory'
tags: ['controller.service_arguments']