Extend ReferrerFilter to render user descriptions and handle "me" referrers in export data generation.

This commit is contained in:
Julien Fastré 2025-06-18 11:55:58 +02:00
parent 81b6ae193c
commit c407c3029f
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 6 additions and 4 deletions

View File

@ -259,7 +259,6 @@ abstract class AbstractFilterTest extends KernelTestCase
public function testDescriptionAction($data)
{
$context = new ExportGenerationContext((new User())->setLabel('test user'));
$description = $this->getFilter()->describeAction($data, $context);
$this->assertTrue(

View File

@ -18,6 +18,7 @@ use Chill\MainBundle\Repository\UserRepositoryInterface;
use Chill\MainBundle\Form\Type\PickUserOrMeDynamicType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@ -32,7 +33,7 @@ final readonly class ReferrerFilter implements FilterInterface
private const PU = 'acp_referrer_filter_users';
public function __construct(private RollingDateConverterInterface $rollingDateConverter, private UserRepositoryInterface $userRepository) {}
public function __construct(private RollingDateConverterInterface $rollingDateConverter, private UserRepositoryInterface $userRepository, private UserRender $userRender) {}
public function addRole(): ?string
{
@ -103,8 +104,8 @@ final readonly class ReferrerFilter implements FilterInterface
{
$users = [];
foreach ($data['accepted_referrers'] as $r) {
$users[] = $r;
foreach ($this->userOrMe($data['accepted_referrers'], $context) as $r) {
$users[] = $this->userRender->renderString($r, []);
}
return [

View File

@ -55,6 +55,8 @@ final class ReferrerFilterTest extends AbstractFilterTest
$data[] = ['accepted_referrers' => $u, 'date_calc' => new RollingDate(RollingDate::T_TODAY)];
}
$data[] = ['accepted_referrers' => 'me', 'date_calc' => new RollingDate(RollingDate::T_TODAY)];
return $data;
}