diff --git a/phpstan-baseline.php b/phpstan-baseline.php index ef695058c..c1ef89ac6 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -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', @@ -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', @@ -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[] = [ @@ -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\\\\:\\: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', @@ -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', @@ -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\\\\.$#', 'identifier' => 'return.type', @@ -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', diff --git a/sources/AppBundle/Calendar/IcsPlanningGenerator.php b/sources/AppBundle/Calendar/IcsPlanningGenerator.php index 46db64d67..38206d3bd 100644 --- a/sources/AppBundle/Calendar/IcsPlanningGenerator.php +++ b/sources/AppBundle/Calendar/IcsPlanningGenerator.php @@ -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, ]); } diff --git a/sources/AppBundle/Calendar/JsonPlanningGenerator.php b/sources/AppBundle/Calendar/JsonPlanningGenerator.php index d0492ca6c..f6157ade0 100644 --- a/sources/AppBundle/Calendar/JsonPlanningGenerator.php +++ b/sources/AppBundle/Calendar/JsonPlanningGenerator.php @@ -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, ]; } diff --git a/sources/AppBundle/Controller/Admin/Event/Session/IndexAction.php b/sources/AppBundle/Controller/Admin/Event/Session/IndexAction.php index 0b9014136..57ece6af6 100644 --- a/sources/AppBundle/Controller/Admin/Event/Session/IndexAction.php +++ b/sources/AppBundle/Controller/Admin/Event/Session/IndexAction.php @@ -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, ); } diff --git a/sources/AppBundle/Controller/Event/Blog/PlanningAction.php b/sources/AppBundle/Controller/Event/Blog/PlanningAction.php index 35c29907c..1ee70e54d 100644 --- a/sources/AppBundle/Controller/Event/Blog/PlanningAction.php +++ b/sources/AppBundle/Controller/Event/Blog/PlanningAction.php @@ -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; } @@ -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, @@ -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; } } diff --git a/sources/AppBundle/Controller/Event/Blog/TalkWidgetAction.php b/sources/AppBundle/Controller/Event/Blog/TalkWidgetAction.php index 34a00e055..e51fab51c 100644 --- a/sources/AppBundle/Controller/Event/Blog/TalkWidgetAction.php +++ b/sources/AppBundle/Controller/Event/Blog/TalkWidgetAction.php @@ -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']; } diff --git a/sources/AppBundle/Event/Entity/Repository/PlanningRepository.php b/sources/AppBundle/Event/Entity/Repository/PlanningRepository.php index 80d447f14..661afd92d 100644 --- a/sources/AppBundle/Event/Entity/Repository/PlanningRepository.php +++ b/sources/AppBundle/Event/Entity/Repository/PlanningRepository.php @@ -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; @@ -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 $talkAggregates * @@ -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 $plannings + * + * @return array + */ + 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); + } } diff --git a/sources/AppBundle/Event/Entity/Repository/RoomRepository.php b/sources/AppBundle/Event/Entity/Repository/RoomRepository.php index 50ecf72ef..989421727 100644 --- a/sources/AppBundle/Event/Entity/Repository/RoomRepository.php +++ b/sources/AppBundle/Event/Entity/Repository/RoomRepository.php @@ -26,4 +26,23 @@ public function getByEvent(Event $event): array { return array_values($this->findBy(['eventId' => $event->getId()])); } + + /** + * @param list $ids + * + * @return array + */ + 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; + } } diff --git a/sources/AppBundle/Event/JsonLd.php b/sources/AppBundle/Event/JsonLd.php index 66f0a3878..19d7a8ad8 100644 --- a/sources/AppBundle/Event/JsonLd.php +++ b/sources/AppBundle/Event/JsonLd.php @@ -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, diff --git a/sources/AppBundle/Event/Model/Repository/RoomRepository.php b/sources/AppBundle/Event/Model/Repository/RoomRepository.php deleted file mode 100644 index 6a8f401f5..000000000 --- a/sources/AppBundle/Event/Model/Repository/RoomRepository.php +++ /dev/null @@ -1,61 +0,0 @@ - - */ -class RoomRepository extends Repository implements MetadataInitializer -{ - /** - * @return CollectionInterface - */ - public function getByEvent(Event $event): CollectionInterface - { - return $this->getBy(['eventId' => $event->getId()]); - } - - /** - * @return Metadata - */ - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - $metadata->setEntity(Room::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_forum_salle'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'nom', - 'fieldName' => 'name', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'id_forum', - 'fieldName' => 'eventId', - 'type' => 'int', - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Event/Model/Repository/TalkRepository.php b/sources/AppBundle/Event/Model/Repository/TalkRepository.php index 967add9b4..9be26dd7e 100644 --- a/sources/AppBundle/Event/Model/Repository/TalkRepository.php +++ b/sources/AppBundle/Event/Model/Repository/TalkRepository.php @@ -182,19 +182,18 @@ public function getByTalkWithSpeakers(Talk $talk) $hydrator->aggregateOn('talk', 'speaker', 'getId'); $query = $this->getPreparedQuery( - // 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(). 'SELECT talk.session_id, talk.titre, skill, talk.genre, abstract, talk.plannifie, speaker.conferencier_id, speaker.nom, speaker.prenom, speaker.id_forum, speaker.photo, speaker.societe, speaker.biographie, - room.id, room.nom, event.date_annonce_planning, event.path, event.interviews_intro, event.interviews_cta_text + event.date_annonce_planning, event.path, event.interviews_intro, event.interviews_cta_text FROM afup_sessions AS talk LEFT JOIN afup_conferenciers_sessions acs ON acs.session_id = talk.session_id LEFT JOIN afup_conferenciers speaker ON speaker.conferencier_id = acs.conferencier_id LEFT JOIN afup_forum_planning planning ON planning.id_session = talk.session_id - LEFT JOIN afup_forum_salle room ON planning.id_salle = room.id LEFT JOIN afup_forum event ON talk.id_forum = event.id WHERE talk.session_id = :talk AND plannifie = 1 AND (talk.date_publication < NOW() OR talk.date_publication IS NULL) - ORDER BY planning.debut ASC, room.id ASC, talk.session_id ASC ', + ORDER BY planning.debut ASC, planning.id_salle ASC, talk.session_id ASC ', )->setParams(['talk' => $talk->getId()]); return $query->query($this->getCollection($hydrator)); @@ -251,16 +250,14 @@ public function getByEventsWithSpeakers(array $events, bool $applyPublicationdat $query = $this->getPreparedQuery( sprintf('SELECT talk.id_forum, talk.session_id, titre, skill, talk.genre, abstract, talk.plannifie, talk.language_code, talk.joindin, talk.theme, talk.position, - speaker.conferencier_id, speaker.nom, speaker.prenom, speaker.id_forum, speaker.photo, speaker.societe, - room.id, room.nom + speaker.conferencier_id, speaker.nom, speaker.prenom, speaker.id_forum, speaker.photo, speaker.societe FROM afup_sessions AS talk LEFT JOIN afup_conferenciers_sessions acs ON acs.session_id = talk.session_id LEFT JOIN afup_conferenciers speaker ON speaker.conferencier_id = acs.conferencier_id LEFT JOIN afup_forum_planning planning ON planning.id_session = talk.session_id - LEFT JOIN afup_forum_salle room ON planning.id_salle = room.id LEFT JOIN afup_conference_theme ON afup_conference_theme.id = talk.theme WHERE talk.id_forum IN(%s) AND plannifie = 1 %s %s - ORDER BY %s ', $inEvents, $publicationdateFilters, $themeFilters, $orderByTheme ? 'afup_conference_theme.priority ASC, afup_conference_theme.name ASC, talk.position IS NULL, talk.position ASC, talk.date_publication DESC, talk.session_id ASC' : 'talk.position IS NULL, talk.position ASC, planning.debut ASC, room.id ASC, talk.date_publication DESC, talk.session_id ASC '), + ORDER BY %s ', $inEvents, $publicationdateFilters, $themeFilters, $orderByTheme ? 'afup_conference_theme.priority ASC, afup_conference_theme.name ASC, talk.position IS NULL, talk.position ASC, talk.date_publication DESC, talk.session_id ASC' : 'talk.position IS NULL, talk.position ASC, planning.debut ASC, planning.id_salle ASC, talk.date_publication DESC, talk.session_id ASC '), )->setParams($params); $result = $query->query($this->getCollection($hydrator)); @@ -270,9 +267,9 @@ public function getByEventsWithSpeakers(array $events, bool $applyPublicationdat $aggregates[] = new TalkAggregate( $row['talk'], $row['.aggregation']['speaker'], - $row['room'] ?? null, - // Les plannings ne sont plus hydratés par Ting : ils sont rechargés - // via Doctrine avec PlanningRepository::enrichTalkAggregates(). + // Les salles et les plannings ne sont plus hydratés par Ting : ils sont + // rechargés via Doctrine avec PlanningRepository::enrichTalkAggregates(). + null, null, ); } @@ -291,14 +288,12 @@ public function getByEventWithSpeakersAndVotes(Event $event, string $search = '' talk.joindin, talk.youtube_id, talk.slides_url, talk.interview_url, talk.blog_post_url, talk.needs_mentoring, talk.date_soumission, speaker.conferencier_id, speaker.nom, speaker.prenom, speaker.id_forum, speaker.photo, speaker.societe, - room.id, room.nom, (SELECT AVG(vote) FROM afup_sessions_vote_github asvg WHERE asvg.session_id = talk.session_id) AS vote_note, (SELECT COUNT(vote) FROM afup_sessions_vote_github asvg WHERE asvg.session_id = talk.session_id) AS vote_total FROM afup_sessions AS talk LEFT JOIN afup_conferenciers_sessions acs ON acs.session_id = talk.session_id LEFT JOIN afup_conferenciers speaker ON speaker.conferencier_id = acs.conferencier_id LEFT JOIN afup_forum_planning planning ON planning.id_session = talk.session_id - LEFT JOIN afup_forum_salle room ON planning.id_salle = room.id WHERE talk.id_forum = :id %s ORDER BY %s SQL; @@ -333,9 +328,9 @@ public function getByEventWithSpeakersAndVotes(Event $event, string $search = '' $aggregates[] = new TalkAggregate( $row['talk'], $row['.aggregation']['speaker'], - $row['room'] ?? null, - // Les plannings ne sont plus hydratés par Ting : ils sont rechargés - // via Doctrine avec PlanningRepository::enrichTalkAggregates(). + // Les salles et les plannings ne sont plus hydratés par Ting : ils sont + // rechargés via Doctrine avec PlanningRepository::enrichTalkAggregates(). + null, null, $row[0]->vote_note ? new TalkAggregateVote($row[0]->vote_note, $row[0]->vote_total) : null, ); diff --git a/sources/AppBundle/Event/Model/Room.php b/sources/AppBundle/Event/Model/Room.php deleted file mode 100644 index c42b9b832..000000000 --- a/sources/AppBundle/Event/Model/Room.php +++ /dev/null @@ -1,85 +0,0 @@ -id; - } - - /** - * @param int $id - * - * @return $this - */ - public function setId($id): self - { - $id = (int) $id; - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - return $this; - } - - /** - * @return mixed - */ - public function getName() - { - return $this->name; - } - - /** - * @param mixed $name - */ - public function setName($name): self - { - $this->propertyChanged('name', $this->name, $name); - $this->name = $name; - return $this; - } - - /** - * @return int - */ - public function getEventId(): ?int - { - return $this->eventId; - } - - /** - * @param int $eventId - * - * @return $this - */ - public function setEventId($eventId): self - { - $eventId = (int) $eventId; - $this->propertyChanged('eventId', $this->eventId, $eventId); - $this->eventId = $eventId; - - return $this; - } -} diff --git a/sources/AppBundle/Event/Model/TalkAggregate.php b/sources/AppBundle/Event/Model/TalkAggregate.php index 0d9d17b53..84acc17bc 100644 --- a/sources/AppBundle/Event/Model/TalkAggregate.php +++ b/sources/AppBundle/Event/Model/TalkAggregate.php @@ -5,6 +5,7 @@ namespace AppBundle\Event\Model; use AppBundle\Event\Entity\Planning; +use AppBundle\Event\Entity\Room; final readonly class TalkAggregate { diff --git a/sources/AppBundle/Event/Speaker/SpeakerPage.php b/sources/AppBundle/Event/Speaker/SpeakerPage.php index ada1f56bc..71f2e28bb 100644 --- a/sources/AppBundle/Event/Speaker/SpeakerPage.php +++ b/sources/AppBundle/Event/Speaker/SpeakerPage.php @@ -9,7 +9,7 @@ use AppBundle\Event\Model\Event; use AppBundle\Event\Model\Repository\SpeakerRepository; use AppBundle\Event\Model\Repository\TalkRepository; -use AppBundle\Event\Model\Room; +use AppBundle\Event\Entity\Room; use AppBundle\Event\Model\Speaker; use AppBundle\Event\Model\Talk; use AppBundle\SpeakerInfos\Form\HotelReservationType; diff --git a/sources/AppBundle/Openfeedback/OpenfeedbackJsonGenerator.php b/sources/AppBundle/Openfeedback/OpenfeedbackJsonGenerator.php index e3e35dad4..d54c0f657 100644 --- a/sources/AppBundle/Openfeedback/OpenfeedbackJsonGenerator.php +++ b/sources/AppBundle/Openfeedback/OpenfeedbackJsonGenerator.php @@ -46,7 +46,7 @@ public function generate(Event $event): array 'tags' => [$talkAggregate->talk->getTypeLabel()], 'title' => $talkAggregate->talk->getTitle(), 'id' => "{$talkAggregate->talk->getId()}", - 'trackTitle' => $talkAggregate->room?->getName() ?? '', + 'trackTitle' => $talkAggregate->room->name ?? '', ]; if (null !== $talkAggregate->planning) { diff --git a/tests/integration/AppBundle/Event/Entity/Repository/PlanningRepositoryTest.php b/tests/integration/AppBundle/Event/Entity/Repository/PlanningRepositoryTest.php index 65763d738..5696f2c20 100644 --- a/tests/integration/AppBundle/Event/Entity/Repository/PlanningRepositoryTest.php +++ b/tests/integration/AppBundle/Event/Entity/Repository/PlanningRepositoryTest.php @@ -7,7 +7,10 @@ use Afup\Tests\Support\IntegrationTestCase; use AppBundle\Event\Entity\Planning; use AppBundle\Event\Entity\Repository\PlanningRepository; +use AppBundle\Event\Entity\Repository\RoomRepository; +use AppBundle\Event\Entity\Room; use AppBundle\Event\Model\Talk; +use AppBundle\Event\Model\TalkAggregate; use Doctrine\DBAL\Connection; final class PlanningRepositoryTest extends IntegrationTestCase @@ -77,6 +80,40 @@ public function testFindNonKeynotesBetween(): void self::assertFalse($planning->isKeynote); } + public function testEnrichTalkAggregatesChargeLePlanningEtLaSalle(): void + { + $planningRepository = self::getContainer()->get(PlanningRepository::class); + $roomRepository = self::getContainer()->get(RoomRepository::class); + $connection = self::getContainer()->get(Connection::class); + + $room = new Room(); + $room->name = 'Salle Rasmus'; + $room->eventId = 10; + $roomRepository->save($room); + + $this->insertPlanning($connection, '1011', '1451606400', '1451608800', (string) $room->id, '10', '0'); + // Planning dont la salle n'existe plus + $this->insertPlanning($connection, '1012', '1451606400', '1451608800', '9999', '10', '0'); + + $aggregates = $planningRepository->enrichTalkAggregates([ + new TalkAggregate(new Talk()->setId(1011), [], null, null), + new TalkAggregate(new Talk()->setId(1012), [], null, null), + // Session non planifiée + new TalkAggregate(new Talk()->setId(1013), [], null, null), + ]); + + self::assertCount(3, $aggregates); + self::assertSame(1011, $aggregates[0]->planning?->talkId); + self::assertSame($room->id, $aggregates[0]->room?->id); + self::assertSame('Salle Rasmus', $aggregates[0]->room->name); + + self::assertSame(1012, $aggregates[1]->planning?->talkId); + self::assertNull($aggregates[1]->room); + + self::assertNull($aggregates[2]->planning); + self::assertNull($aggregates[2]->room); + } + /** * @return void */