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
50 changes: 1 addition & 49 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2311,12 +2311,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/IndexAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#5 \\$resourceId of class AppBundle\\\\Event\\\\Model\\\\Session\\\\CalendarEvent constructor expects int, int\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/IndexAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#3 \\$speaker of method AppBundle\\\\Event\\\\Speaker\\\\SpeakerPage\\:\\:handleRequest\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Speaker, AppBundle\\\\Event\\\\Model\\\\Speaker\\|null given\\.$#',
'identifier' => 'argument.type',
Expand Down Expand Up @@ -3199,12 +3193,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Blog/PlanningAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getId\\(\\) on AppBundle\\\\Event\\\\Model\\\\Room\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 3,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Blog/PlanningAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method setTimezone\\(\\) on DateTime\\|null\\.$#',
'identifier' => 'method.nonObject',
Expand All @@ -3220,7 +3208,7 @@
$ignoreErrors[] = [
'message' => '#^Possibly invalid array key type int\\|null\\.$#',
'identifier' => 'offsetAccess.invalidOffset',
'count' => 6,
'count' => 3,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/Blog/PlanningAction.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -5113,24 +5101,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/InvoiceRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\RoomRepository\\:\\: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/RoomRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\RoomRepository\\:\\:initMetadata\\(\\) return type with generic class CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata does not specify its types\\: T$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/RoomRepository.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/RoomRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset 0 on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down Expand Up @@ -5227,12 +5197,6 @@
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'room\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'speaker\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down Expand Up @@ -5371,12 +5335,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#3 \\$room of class AppBundle\\\\Event\\\\Model\\\\TalkAggregate constructor expects AppBundle\\\\Event\\\\Model\\\\Room\\|null, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TicketEventTypeHydrationRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\.$#',
'identifier' => 'return.type',
Expand Down Expand Up @@ -5581,12 +5539,6 @@
'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',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Room.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Speaker\\:\\:getHotelNightsArray\\(\\) return type has no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Calendar/IcsPlanningGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function generateForEvent(Event $event): string
'DTSTART' => $talkAggregate->planning->start,
'DTEND' => $talkAggregate->planning->end,
'DESCRIPTION' => strip_tags(html_entity_decode($talkAggregate->talk->getAbstract())),
'LOCATION' => $talkAggregate->room->getName(),
'LOCATION' => $talkAggregate->room->name,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Calendar/JsonPlanningGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function generate(Event $event): array
'id' => $talkAggregate->talk->getId(),
'lang' => $talkAggregate->talk->getLanguageLabel(),
'name' => $talkAggregate->talk->getTitle(),
'salle' => $talkAggregate->room->getName(),
'salle' => $talkAggregate->room->name,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function calendarEvents(array $sessions): array
$session->talk->getTitle(),
$this->formatForCalendar($session->planning->start, $timezone),
$this->formatForCalendar($session->planning->end, $timezone),
$session->room->getId(),
$session->room->id,
);
}

Expand Down
8 changes: 4 additions & 4 deletions sources/AppBundle/Controller/Event/Blog/PlanningAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __invoke(Request $request, string $eventSlug): Response
$planning = $talkAggregate->planning;
$room = $talkAggregate->room;

if ($planning === null) {
if ($planning === null || $room === null) {
continue;
}

Expand Down Expand Up @@ -86,7 +86,7 @@ public function __invoke(Request $request, string $eventSlug): Response
$defaultProgramPagePrefix = $request->query->get('program-page-prefix-' . $eventPath, '/' . $eventPath . '/programme/');
}

$eventPlanning[$startDay][$start][$room->getId()][] = [
$eventPlanning[$startDay][$start][$room->id][] = [
'talk' => $talkAggregate->talk,
'speakers' => $talkAggregate->speakers,
'room' => $talkAggregate->room,
Expand All @@ -95,8 +95,8 @@ public function __invoke(Request $request, string $eventSlug): Response
'length' => $interval->i + $interval->h * 60,
];

if (isset($rooms[$room->getId()]) === false) {
$rooms[$room->getId()] = $room;
if (isset($rooms[$room->id]) === false) {
$rooms[$room->id] = $room;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ public function __invoke(Request $request): Response

$talkIds = array_map(static fn($talk) => (int) $talk->getId(), iterator_to_array($talks, false));
$plannings = $this->planningRepository->findIndexedByTalkIds($talkIds);
$rooms = $this->planningRepository->findRoomsOf($plannings);

$event = null;
$speakers = [];
$talksInfos = [];
foreach ($talks as $talk) {
foreach ($this->talkRepository->getByTalkWithSpeakers($talk) as $row) {
// Les plannings ne sont plus hydratés par Ting : ils sont rechargés
// via Doctrine avec PlanningRepository::findIndexedByTalkIds().
// Les salles et les plannings ne sont plus hydratés par Ting : ils sont
// rechargés via Doctrine avec PlanningRepository::findIndexedByTalkIds().
$row['planning'] = $talk->getId() !== null ? ($plannings[$talk->getId()] ?? null) : null;
$row['room'] = $row['planning']?->roomId !== null ? ($rooms[$row['planning']->roomId] ?? null) : null;
if (($row['event'] ?? null) instanceof Event) {
$event = $row['event'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use AppBundle\Doctrine\EntityRepository;
use AppBundle\Doctrine\Type\UnixTimestampType;
use AppBundle\Event\Entity\Planning;
use AppBundle\Event\Entity\Room;
use AppBundle\Event\Model\Talk;
use AppBundle\Event\Model\TalkAggregate;
use Doctrine\Persistence\ManagerRegistry;
Expand Down Expand Up @@ -72,8 +73,8 @@ public function findIndexedByTalkIds(array $talkIds): array
}

/**
* Complète les agrégats session/conférenciers/salle produits par TalkRepository (Ting)
* avec les plannings correspondants, rechargés via Doctrine.
* Complète les agrégats session/conférenciers produits par TalkRepository (Ting)
* avec les plannings et les salles correspondants, rechargés via Doctrine.
*
* @param array<TalkAggregate> $talkAggregates
*
Expand All @@ -90,19 +91,38 @@ public function enrichTalkAggregates(array $talkAggregates): array
}

$plannings = $this->findIndexedByTalkIds($talkIds);
$rooms = $this->findRoomsOf($plannings);

$enriched = [];
foreach ($talkAggregates as $talkAggregate) {
$talkId = $talkAggregate->talk->getId();
$planning = $talkId !== null ? ($plannings[$talkId] ?? null) : null;
$enriched[] = new TalkAggregate(
$talkAggregate->talk,
$talkAggregate->speakers,
$talkAggregate->room,
$talkId !== null ? ($plannings[$talkId] ?? null) : null,
$planning?->roomId !== null ? ($rooms[$planning->roomId] ?? null) : null,
$planning,
$talkAggregate->vote,
);
}

return $enriched;
}

/**
* @param array<Planning> $plannings
*
* @return array<int, Room>
*/
public function findRoomsOf(array $plannings): array
{
$roomIds = [];
foreach ($plannings as $planning) {
if ($planning->roomId !== null) {
$roomIds[] = $planning->roomId;
}
}

return $this->getEntityManager()->getRepository(Room::class)->findIndexedByIds($roomIds);
}
}
19 changes: 19 additions & 0 deletions sources/AppBundle/Event/Entity/Repository/RoomRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,23 @@ public function getByEvent(Event $event): array
{
return array_values($this->findBy(['eventId' => $event->getId()]));
}

/**
* @param list<int> $ids
*
* @return array<int, Room>
*/
public function findIndexedByIds(array $ids): array
{
if ($ids === []) {
return [];
}

$rooms = [];
foreach ($this->findBy(['id' => array_values(array_unique($ids))]) as $room) {
$rooms[$room->id] = $room;
}

return $rooms;
}
}
2 changes: 1 addition & 1 deletion sources/AppBundle/Event/JsonLd.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getDataForEvent(Event $event): array
'description' => html_entity_decode(strip_tags((string) $talkAggregate->talk->getDescription())),
'location' => [
'@type' => 'Place',
'name' => $talkAggregate->room?->getName() ?? '',
'name' => $talkAggregate->room->name ?? '',
'address' => $event->getPlaceAddress(),
],
'performers' => $performers,
Expand Down
61 changes: 0 additions & 61 deletions sources/AppBundle/Event/Model/Repository/RoomRepository.php

This file was deleted.

Loading
Loading