Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 10 additions & 70 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2192,17 +2192,11 @@
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PreviousRegistrationsAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getId\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'message' => '#^Cannot access property \\$id on AppBundle\\\\Event\\\\Entity\\\\TicketType\\|null\\.$#',
'identifier' => 'property.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesAddAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getId\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/PricesEditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Controller\\\\Admin\\\\Event\\\\RedirectEventFromSessionListener\\:\\:__construct\\(\\) has parameter \\$controllersWithEventSelector with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand Down Expand Up @@ -4406,8 +4400,8 @@
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketInvoiceType.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToCfpSubmitter\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'message' => '#^Cannot access property \\$isRestrictedToCfpSubmitter on AppBundle\\\\Event\\\\Entity\\\\TicketType\\|null\\.$#',
'identifier' => 'property.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TicketType.php',
];
Expand Down Expand Up @@ -5395,18 +5389,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'aft\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'afto\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'sold_tickets\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down Expand Up @@ -5551,36 +5533,12 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#2 \\$ticketType of class AppBundle\\\\Event\\\\Model\\\\TicketAggregate constructor expects AppBundle\\\\Event\\\\Model\\\\TicketType, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#3 \\$invoice of class AppBundle\\\\Event\\\\Model\\\\TicketAggregate constructor expects AppBundle\\\\Event\\\\Model\\\\Invoice\\|null, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketTypeRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketTypeRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TicketTypeRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Property AppBundle\\\\Event\\\\Model\\\\Room\\:\\:\\$name \\(string\\) does not accept mixed\\.$#',
'identifier' => 'assign.propertyType',
Expand Down Expand Up @@ -5665,18 +5623,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Ticket.php',
];
$ignoreErrors[] = [
'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#',
'identifier' => 'foreach.nonIterable',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/TicketType.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\TicketType\\:\\:getDays\\(\\) has no return type specified\\.$#',
'identifier' => 'missingType.return',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/TicketType.php',
];
$ignoreErrors[] = [
'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#',
'identifier' => 'foreach.nonIterable',
Expand Down Expand Up @@ -6031,12 +5977,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/TicketTypeAvailability.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Ticket/TicketTypeAvailability.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Validator\\\\Constraints\\\\AvailableTicketValidator\\:\\:validate\\(\\) has parameter \\$ticket with no type specified\\.$#',
'identifier' => 'missingType.parameter',
Expand All @@ -6062,8 +6002,8 @@
'path' => __DIR__ . '/sources/AppBundle/Event/Validator/Constraints/CorporateMemberValidator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToMembers\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'message' => '#^Cannot access property \\$isRestrictedToMembers on AppBundle\\\\Event\\\\Entity\\\\TicketType\\|null\\.$#',
'identifier' => 'property.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Validator/Constraints/CorporateMemberValidator.php',
];
Expand All @@ -6074,8 +6014,8 @@
'path' => __DIR__ . '/sources/AppBundle/Event/Validator/Constraints/CorporateMemberValidator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToMembers\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'message' => '#^Cannot access property \\$isRestrictedToMembers on AppBundle\\\\Event\\\\Entity\\\\TicketType\\|null\\.$#',
'identifier' => 'property.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Validator/Constraints/LoggedInMemberValidator.php',
];
Expand All @@ -6086,8 +6026,8 @@
'path' => __DIR__ . '/sources/AppBundle/Event/Validator/Constraints/LoggedInMemberValidator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIsRestrictedToMembers\\(\\) on AppBundle\\\\Event\\\\Model\\\\TicketType\\|null\\.$#',
'identifier' => 'method.nonObject',
'message' => '#^Cannot access property \\$isRestrictedToMembers on AppBundle\\\\Event\\\\Entity\\\\TicketType\\|null\\.$#',
'identifier' => 'property.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Validator/Constraints/PublicTicketValidator.php',
];
Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Association/Form/TicketEventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace AppBundle\Association\Form;

use AppBundle\Event\Entity\TicketEventType as ModelTicketEventType;
use AppBundle\Event\Model\TicketType;
use AppBundle\Event\Entity\TicketType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use AppBundle\Event\AdminEventSelection;
use AppBundle\Event\Entity\Repository\TicketEventTypeRepository;
use AppBundle\Event\Entity\TicketEventType as ModelTicketEventType;
use AppBundle\Event\Model\Repository\TicketTypeRepository;
use AppBundle\Event\Entity\Repository\TicketTypeRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -33,15 +33,15 @@ public function __invoke(Request $request, AdminEventSelection $eventSelection):
$ticketEventType->dateStart = $event->getDateStart() ?? new \DateTime();
$ticketEventType->dateEnd = $event->getDateEnd() ?? new \DateTime();

$ticketTypes = $this->ticketTypeRepository->getAll();
$ticketTypes = $this->ticketTypeRepository->findAllOrderedById();
$form = $this->createForm(TicketEventType::class, $ticketEventType, [
'ticketTypes' => $ticketTypes,
'has_prices_defined_with_vat' => $event->hasPricesDefinedWithVat(),
]);

$form->handleRequest($request);
if ($form->isSubmitted()) {
$ticketEventType->ticketTypeId = $ticketEventType->ticketType->getId();
$ticketEventType->ticketTypeId = $ticketEventType->ticketType->id;

// Vérification maison d'unicité : la clé primaire est composée de (ticketTypeId, eventId)
$existant = $this->ticketEventTypeRepository->findOneBy([
Expand Down
11 changes: 7 additions & 4 deletions sources/AppBundle/Controller/Admin/Event/PricesEditAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use AppBundle\Controller\Event\EventActionHelper;
use AppBundle\Event\Form\EventSelectType;
use AppBundle\Event\Entity\Repository\TicketEventTypeRepository;
use AppBundle\Event\Model\Repository\TicketTypeRepository;
use AppBundle\Event\Entity\Repository\TicketTypeRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -29,18 +29,21 @@ public function __construct(
public function __invoke(Request $request, int $event, int $id): Response
{
$event = $this->eventActionHelper->getEventById($event);
$ticketType = $this->ticketTypeRepository->get($id);
$ticketType = $this->ticketTypeRepository->find($id);
if ($ticketType === null) {
throw new NotFoundHttpException();
}

$ticketEventType = $this->ticketEventTypeRepository->find([
'eventId' => $event->getId(),
'ticketTypeId' => $ticketType->getId(),
'ticketTypeId' => $ticketType->id,
]);
if ($ticketEventType === null) {
throw new NotFoundHttpException();
}
$ticketEventType->ticketType = $ticketType;

$ticketTypes = $this->ticketTypeRepository->getAll();
$ticketTypes = $this->ticketTypeRepository->findAllOrderedById();
$form = $this->createForm(TicketEventType::class, $ticketEventType, [
'ticketTypes' => $ticketTypes,
'has_prices_defined_with_vat' => $event->hasPricesDefinedWithVat(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use AppBundle\Event\AdminEventSelection;
use AppBundle\Event\Entity\Repository\BilleteriePriveeRepository;
use AppBundle\Event\Entity\Repository\TicketSpecialPriceRepository;
use AppBundle\Event\Entity\Repository\TicketTypeRepository;
use AppBundle\Event\Model\Event;
use AppBundle\Event\Model\EventStats;
use AppBundle\Event\Model\Repository\EventStatsRepository;
Expand Down Expand Up @@ -35,6 +36,7 @@ public function __construct(
private readonly BilleteriePriveeRepository $billeteriePriveeRepository,
private readonly TicketSpecialPriceRepository $ticketSpecialPriceRepository,
private readonly FormFactoryInterface $formFactory,
private readonly TicketTypeRepository $ticketTypeRepository,
) {}

public function __invoke(Request $request, AdminEventSelection $eventSelection): Response
Expand All @@ -54,12 +56,12 @@ public function __invoke(Request $request, AdminEventSelection $eventSelection):
$data['sort_direction'] ??= 'desc';

$statistics = $this->eventStatsRepository->getStats($event->getId());
$tickets = $this->ticketRepository->getByEventWithAll(
$tickets = $this->ticketTypeRepository->enrichTicketAggregates($this->ticketRepository->getByEventWithAll(
event: $event,
search: $data['filter'] ?? null,
sortKey: $data['sort_key'],
sortDirection: $data['sort_direction'],
);
));
$computed = $this->computeStatistics($statistics, $event);
$specialPriceLabels = $this->getSpecialPriceLabels($tickets);

Expand Down Expand Up @@ -87,7 +89,7 @@ private function getSpecialPriceLabels(array $tickets): array
$tokens = [];
foreach ($tickets as $aggregate) {
if (
$aggregate->ticketType->getId() === Ticket::TYPE_SPECIAL_PRICE
$aggregate->ticketType?->id === Ticket::TYPE_SPECIAL_PRICE
&& $aggregate->ticket->getSpecialPriceToken() !== null
) {
$tokens[] = $aggregate->ticket->getSpecialPriceToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function __invoke($eventSlug, Request $request): Response

foreach ($tickets as $ticket) {
if ($ticket->getTicketEventType()?->ticketType !== null
&& $ticket->getTicketEventType()->ticketType->getIsRestrictedToMembers()
&& $ticket->getTicketEventType()->ticketType->isRestrictedToMembers
&& isset($memberId, $memberType)) {
$ticket
->setMemberId($memberId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use AppBundle\Doctrine\EntityRepository;
use AppBundle\Event\Entity\TicketEventType;
use AppBundle\Event\Model\Event;
use AppBundle\Event\Model\Repository\TicketTypeRepository;
use AppBundle\Event\Entity\TicketType;
use Doctrine\Persistence\ManagerRegistry;

/**
Expand All @@ -19,10 +19,8 @@ final class TicketEventTypeRepository extends EntityRepository
public const int REMOVE_FUTURE_TICKETS = 2;
public const int ACTUAL_TICKETS_ONLY = 3; // Combinaison de REMOVE_PAST_TICKETS et REMOVE_FUTURE_TICKETS

public function __construct(
ManagerRegistry $registry,
private readonly TicketTypeRepository $ticketTypeRepository,
) {
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, TicketEventType::class);
}

Expand Down Expand Up @@ -58,11 +56,6 @@ public function getTicketsByEvent(Event $event, bool $publicOnly = true, ?int $d
->addOrderBy('tarif_event.price')
->addOrderBy('tarif.members_only', 'DESC');

$ticketTypes = [];
foreach ($this->ticketTypeRepository->getAll() as $ticketType) {
$ticketTypes[$ticketType->getId()] = $ticketType;
}

$ticketEventTypes = [];
foreach ($queryBuilder->executeQuery()->fetchAllAssociative() as $row) {
if (!isset($row['id_tarif'], $row['id_event'])
Expand All @@ -78,10 +71,11 @@ public function getTicketsByEvent(Event $event, bool $publicOnly = true, ?int $d
if ($ticketEventType === null) {
continue;
}
$ticketEventType->ticketType = $ticketTypes[$ticketEventType->ticketTypeId] ?? null;
$ticketEventTypes[] = $ticketEventType;
}

$this->getEntityManager()->getRepository(TicketType::class)->attachTo($ticketEventTypes);

return $ticketEventTypes;
}

Expand All @@ -91,7 +85,7 @@ public function getTicketsByEvent(Event $event, bool $publicOnly = true, ?int $d
public function doesEventHasRestrictedToMembersTickets(Event $event, bool $publicOnly = true, ?int $datesFilter = null): bool
{
foreach ($this->getTicketsByEvent($event, $publicOnly, $datesFilter) as $ticketEventType) {
if ($ticketEventType->ticketType?->getIsRestrictedToMembers() === true) {
if ($ticketEventType->ticketType?->isRestrictedToMembers === true) {
return true;
}
}
Expand Down
Loading
Loading