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

@@ -16,7 +16,7 @@ use Symfony\Component\EventDispatcher\Event;
/**
* Event triggered when an entity attached to a person is removed.
*/
class ActionEvent extends Event
class ActionEvent extends \Symfony\Contracts\EventDispatcher\Event
{
final public const DELETE = 'CHILL_PERSON.DELETE_ASSOCIATED_ENTITY';

View File

@@ -100,7 +100,7 @@ class PersonMove
$sql,
['to' => $to->getId(), 'original_action' => 'move']
);
$this->eventDispatcher->dispatch(ActionEvent::DELETE, $event);
$this->eventDispatcher->dispatch($event, ActionEvent::DELETE);
} else {
$sql = $this->createMoveSQL($metadata, $from, $to, $field);
$event = new ActionEvent(
@@ -109,7 +109,7 @@ class PersonMove
$sql,
['to' => $to->getId(), 'original_action' => 'move']
);
$this->eventDispatcher->dispatch(ActionEvent::MOVE, $event);
$this->eventDispatcher->dispatch($event, ActionEvent::MOVE);
}
$sqls = array_merge($sqls, $event->getPreSql(), [$event->getSqlStatement()], $event->getPostSql());

View File

@@ -26,7 +26,7 @@ class ChillPersonBundle extends Bundle
$container->getExtension('chill_main')
->addWidgetFactory(new PersonListWidgetFactory());
$container->addCompilerPass(new AccompanyingPeriodTimelineCompilerPass());
$container->addCompilerPass(new AccompanyingPeriodTimelineCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
$container->registerForAutoconfiguration(AccompanyingPeriodInfoUnionQueryPartInterface::class)
->addTag('chill_person.accompanying_period_info_part');
}

View File

@@ -335,11 +335,11 @@ final class AccompanyingCourseApiController extends ApiController
protected function onPostCheckACL(string $action, Request $request, string $_format, $entity): ?Response
{
$this->eventDispatcher->dispatch(
AccompanyingPeriodPrivacyEvent::ACCOMPANYING_PERIOD_PRIVACY_EVENT,
new AccompanyingPeriodPrivacyEvent($entity, [
'action' => $action,
'request' => $request->getMethod(),
])
]),
AccompanyingPeriodPrivacyEvent::ACCOMPANYING_PERIOD_PRIVACY_EVENT
);
return null;

View File

@@ -39,7 +39,7 @@ use function is_array;
/**
* Class AccompanyingCourseController.
*/
class AccompanyingCourseController extends Controller
class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
{
public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly Registry $registry, private readonly TranslatorInterface $translator)
{

View File

@@ -72,11 +72,9 @@ class AccompanyingPeriodController extends AbstractController
['%name%' => $person->__toString()]
));
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
])
);
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
]);
}
$current = $person->getCurrentAccompanyingPeriod();
@@ -102,11 +100,9 @@ class AccompanyingPeriodController extends AbstractController
$this->getDoctrine()->getManager()->flush();
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
])
);
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
]);
}
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
@@ -182,11 +178,9 @@ class AccompanyingPeriodController extends AbstractController
)
);
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
])
);
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
]);
}
$flashBag->add('error', $this->get('translator')
->trans('Error! Period not created!'));
@@ -214,7 +208,7 @@ class AccompanyingPeriodController extends AbstractController
'element_class' => AccompanyingPeriod::class,
'action' => 'list',
]);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
$accompanyingPeriods = $this->accompanyingPeriodACLAwareRepository
->findByPerson($person, AccompanyingPeriodVoter::SEE, ["openingDate" => "DESC", "id" => "DESC"]);
@@ -249,11 +243,9 @@ class AccompanyingPeriodController extends AbstractController
['%name%' => $person->__toString()]
));
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
])
);
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
]);
}
$accompanyingPeriod = new AccompanyingPeriod(new DateTime());
@@ -285,11 +277,9 @@ class AccompanyingPeriodController extends AbstractController
$this->getDoctrine()->getManager()->flush();
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
])
);
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
]);
}
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
@@ -414,11 +404,9 @@ class AccompanyingPeriodController extends AbstractController
$this->get('translator')->trans('An accompanying period has been updated.')
);
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
])
);
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person->getId(),
]);
}
$flashBag->add('error', $this->get('translator')

View File

@@ -143,7 +143,7 @@ final class PersonController extends AbstractController
);
$event = new PrivacyEvent($person);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
return $this->render(
'@ChillPerson/Person/household_history.html.twig',
@@ -272,7 +272,7 @@ final class PersonController extends AbstractController
);
$event = new PrivacyEvent($person);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
return $this->render(
'ChillPersonBundle:Person:view.html.twig',

View File

@@ -32,7 +32,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
class PersonDuplicateController extends Controller
class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
{
public function __construct(private readonly SimilarPersonMatcher $similarPersonMatcher, private readonly TranslatorInterface $translator, private readonly PersonRepository $personRepository, private readonly PersonMove $personMove, private readonly EventDispatcherInterface $eventDispatcher)
{
@@ -76,7 +76,7 @@ class PersonDuplicateController extends Controller
'action' => 'move',
]);
$event->addPerson($person2);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
$sqls = $this->personMove->getSQL($person2, $person1);

View File

@@ -46,7 +46,7 @@ class TimelinePersonController extends AbstractController
$paginator = $this->paginatorFactory->create($nbItems);
$event = new PrivacyEvent($person, ['action' => 'timeline']);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
return $this->render(
'ChillPersonBundle:Timeline:index.html.twig',

View File

@@ -34,7 +34,7 @@ namespace Chill\PersonBundle\Privacy;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Symfony\Component\EventDispatcher\Event;
class AccompanyingPeriodPrivacyEvent extends Event
class AccompanyingPeriodPrivacyEvent extends \Symfony\Contracts\EventDispatcher\Event
{
final public const ACCOMPANYING_PERIOD_PRIVACY_EVENT = 'chill_person.accompanying_period_privacy_event';

View File

@@ -42,7 +42,7 @@ use function count;
* Array $args expects arguments with the following keys: 'element_class', 'element_id', 'action'
* By default, action is set to 'show'
*/
class PrivacyEvent extends Event
class PrivacyEvent extends \Symfony\Contracts\EventDispatcher\Event
{
final public const PERSON_PRIVACY_EVENT = 'chill_person.privacy_event';

View File

@@ -37,7 +37,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
public const OPENING_INPUT = 'chill_personbundle_accompanyingperiod[openingDate]';
/**
* @var \Symfony\Component\BrowserKit\Client
* @var \Symfony\Component\BrowserKit\AbstractBrowser
*/
protected $client;

View File

@@ -21,7 +21,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class PersonAddressControllerTest extends WebTestCase
{
/**
* @var \Symfony\Component\BrowserKit\Client
* @var \Symfony\Component\BrowserKit\AbstractBrowser
*/
protected $client;

View File

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

View File

@@ -2,4 +2,4 @@ services:
Chill\PersonBundle\Actions\Remove\PersonMove:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'

View File

@@ -5,7 +5,7 @@ services:
Chill\PersonBundle\Controller\TimelinePersonController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
$timelineBuilder: '@chill_main.timeline_builder'
$paginatorFactory: '@chill_main.paginator_factory'
tags: ['controller.service_arguments']
@@ -28,7 +28,7 @@ services:
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
$personRepository: '@Chill\PersonBundle\Repository\PersonRepository'
$personMove: '@Chill\PersonBundle\Actions\Remove\PersonMove'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseController:

View File

@@ -8,7 +8,7 @@ services:
# Chill\PersonBundle\Menu\SectionMenuBuilder:
# arguments:
# $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
# $translator: '@Symfony\Component\Translation\TranslatorInterface'
# $translator: '@Symfony\Contracts\Translation\TranslatorInterface'
# tags:
# - { name: 'chill.menu_builder' }
#