This commit introduces a new filter to the Accompanying Course section. It allows users to filter for courses that are not associated with a reference address. The accompanying test and translation changes are also included in this update.
Replaced most of the invocations of getDoctrine()->getManager() with ManagerRegistry->getManager(), and added ManagerRegistry injection to controllers where needed. This is part of an ongoing effort to improve code clarity, and avoid unnecessary method chaining in various parts of the codebase.
This change is made to comply with the new Symfony standards and to avoid deprecation warnings for future versions. The update touches various functionalities, including retrieving EntityManagerInterface instance and various service classes within the test files.
Removed the ReportSearch class from ChillReportBundle and updated the corresponding services configuration. This removal is part of a larger refactoring process to enhance maintainability, eliminate unused code and simplify application architecture. This will not affect the application's functionality as the class was not used.
Removed unnecessary comments and added type hinting to the function parseDate in the AbstractSearch class. Any string passed to this function will now explicitly be expected as a string data type, increasing code robustness and easing debugging process.
This update adds a new filter, WithParticipationBetweenDatesFilter, to the ChillPersonBundle. This filter helps to find persons who participated in any parcours between specified date ranges. Additionally, relevant French translations have been updated and the filter has been registered in the services configuration file.
En symfony 5.4 le typage a été vraiment amélioré, et phpstan peut détecter plus d'erreur potentielles.
Mais le problème est que Symfony "type" les `User` avec son propre `Symfony\Component\Security\Core\User\UserInterface` alors qu'on a besoin de `Chill\MainBundle\Entity\User`.
Imaginons qu'on a ceci:
```php
namespace Chill\Bundle\Service;
final readonly class SomeService
{
public function myMethod(\Chill\MainBundle\Entity\User $user): void
{
// ...
}
}
```
Quand on l'appelle dans un contrôleur ou dans un service:
```php
namespace Chill\Bundle\Service;
use Symfony\Component\Security\Core\Security;
final readonly OtherService
{
public function __construct(private Security $security, private SomeService $service) {}
public function __invoke(): void
{
$this->service->myMethod($this->security->getUser());
}
}
```
PHPstan va se plaindre:
```
Parameter #1 $user of method SomeService::myMethod() expects Chill\MainBundle\Entity\User, Symfony\Component\Security\Core\User\UserInterface|null given.
```
Du coup, j'ai créé ce service:
```php
<?php
namespace Chill\MainBundle\Security;
use Chill\MainBundle\Entity\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Security;
/**
* Security helper for Chill user
*
* Provides security-related functionality such as user retrieval, authorization checks,
* and token retrieval, in a context where only an authenticated @see{User::class} is expected.
*
*/
final readonly class ChillSecurity implements AuthorizationCheckerInterface
{
public function hasUser(): bool
{
// implementation detail not shown here
}
public function getUser(): User
{
// implementation detail not shown here
}
public function isGranted($attribute, $subject = null): bool
{
// implementation detail not shown here
}
public function getToken(): ?TokenInterface
{
// implementation detail not shown here
}
}
```
Et maintenant, on peut faire:
```php
namespace Chill\Bundle\Service;
use Chill\MainBundle\Security\ChillSecurity;
final readonly OtherService
{
public function __construct(private ChillSecurity $security, private SomeService $service) {}
public function __invoke(): void
{
$this->service->myMethod($this->security->getUser());
}
}
```
Et tout va bien se passer.
Ca sera dans la version de chill qui fait passer à symfony 5.4.