From edbb4d5a3cc6a299044ff1d06dbf74d23be379bf Mon Sep 17 00:00:00 2001 From: Nathan Boiron Date: Tue, 18 Aug 2026 23:19:59 +0200 Subject: [PATCH 1/3] =?UTF-8?q?R=C3=A9cup=C3=A9ration=20des=20donn=C3=A9es?= =?UTF-8?q?=20des=20interviews?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand on arrive sur la page de liste des interviews, s'il n'y a pas d'id d'event en session, on va récupérer le plus récent. Dans ce cas, l'event est chargé sans les données wordpress pour les interviews, et la page de gestion des interviews affiche ces données comme manquantes, ce qui force une navigation inutile. --- sources/AppBundle/Event/Model/Repository/EventRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/AppBundle/Event/Model/Repository/EventRepository.php b/sources/AppBundle/Event/Model/Repository/EventRepository.php index 7a668a443..e95f33da5 100644 --- a/sources/AppBundle/Event/Model/Repository/EventRepository.php +++ b/sources/AppBundle/Event/Model/Repository/EventRepository.php @@ -44,7 +44,7 @@ public function getNextEvent(): ?Event public function getNextEvents(): ?CollectionInterface { $query = $this - ->getQuery('SELECT id, path, titre, text, date_debut, date_fin, date_debut_appel_conferencier, date_fin_appel_conferencier, date_fin_vente, nb_places FROM afup_forum WHERE date_debut > NOW() ORDER BY date_debut') + ->getQuery('SELECT id, path, titre, text, date_debut, date_fin, date_debut_appel_conferencier, date_fin_appel_conferencier, date_fin_vente, nb_places, interviews_wp_category_id, interviews_intro, interviews_cta_text FROM afup_forum WHERE date_debut > NOW() ORDER BY date_debut') ; $events = $query->query($this->getCollection(new HydratorSingleObject())); From b1e9e96701f6fb7e25f6edf05c3be35b75884c05 Mon Sep 17 00:00:00 2001 From: Nathan Boiron Date: Tue, 18 Aug 2026 23:20:24 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Correction=20de=20l'url=20d'aper=C3=A7u?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/admin/event/interview/list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/event/interview/list.html.twig b/templates/admin/event/interview/list.html.twig index d19ebfd30..ce0cc4902 100644 --- a/templates/admin/event/interview/list.html.twig +++ b/templates/admin/event/interview/list.html.twig @@ -51,7 +51,7 @@ {% if row.interview.wordpressPostId is not null %} - From 72ae3801c1c82ec88b42118d50eb87fffd33e78c Mon Sep 17 00:00:00 2001 From: Nathan Boiron Date: Tue, 18 Aug 2026 23:55:02 +0200 Subject: [PATCH 3/3] =?UTF-8?q?R=C3=A9cup=C3=A9ration=20du=20slug=20g?= =?UTF-8?q?=C3=A9n=C3=A9r=C3=A9=20=C3=A0=20la=20sauvegarde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Si on a le slug, l'url de preview l'utilise. --- ...525_add_word_press_post_slug_to_events.php | 20 +++++++++++++++++++ .../Admin/Event/Interview/AddOrEditAction.php | 5 +++-- sources/AppBundle/Event/Entity/Interview.php | 3 +++ .../Wordpress/Dto/PersistedInterview.php | 13 ++++++++++++ .../Event/Wordpress/HttpWordpressClient.php | 10 ++++++---- .../Event/Wordpress/WordpressClient.php | 3 ++- .../admin/event/interview/list.html.twig | 13 +++++++++++- .../support/Wordpress/FakeWordpressClient.php | 5 +++-- 8 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 db/migrations/20260818212525_add_word_press_post_slug_to_events.php create mode 100644 sources/AppBundle/Event/Wordpress/Dto/PersistedInterview.php diff --git a/db/migrations/20260818212525_add_word_press_post_slug_to_events.php b/db/migrations/20260818212525_add_word_press_post_slug_to_events.php new file mode 100644 index 000000000..5e3f0ec69 --- /dev/null +++ b/db/migrations/20260818212525_add_word_press_post_slug_to_events.php @@ -0,0 +1,20 @@ +table('interview') + ->addColumn('wordpress_post_slug', 'string', [ + 'null' => true, + 'default' => null, + ]) + ->save() + ; + } +} diff --git a/sources/AppBundle/Controller/Admin/Event/Interview/AddOrEditAction.php b/sources/AppBundle/Controller/Admin/Event/Interview/AddOrEditAction.php index 45bde0fe1..3d66aa673 100644 --- a/sources/AppBundle/Controller/Admin/Event/Interview/AddOrEditAction.php +++ b/sources/AppBundle/Controller/Admin/Event/Interview/AddOrEditAction.php @@ -123,14 +123,15 @@ private function saveToWordpress(Interview $interview, Event $event): bool } try { - $wordpressPostId = $this->wordpressClient->persistInterview( + $persistedInterview = $this->wordpressClient->persistInterview( $interview, $event, $interview->speakers->toArray(), $plannedTalks, ); - $interview->wordpressPostId = $wordpressPostId; + $interview->wordpressPostId = $persistedInterview->id; + $interview->wordpressPostSlug = $persistedInterview->slug; $this->interviewRepository->save($interview); return true; diff --git a/sources/AppBundle/Event/Entity/Interview.php b/sources/AppBundle/Event/Entity/Interview.php index 9cb4465b7..fbe6f6ec7 100644 --- a/sources/AppBundle/Event/Entity/Interview.php +++ b/sources/AppBundle/Event/Entity/Interview.php @@ -28,6 +28,9 @@ class Interview #[ORM\Column(name: 'wordpress_post_id', nullable: true)] public ?int $wordpressPostId = null; + #[ORM\Column(name: 'wordpress_post_slug', nullable: true)] + public ?string $wordpressPostSlug = null; + /** @var Collection */ #[ORM\JoinTable(name: 'interview_speaker')] #[ORM\JoinColumn(name: 'interview_id', referencedColumnName: 'id')] diff --git a/sources/AppBundle/Event/Wordpress/Dto/PersistedInterview.php b/sources/AppBundle/Event/Wordpress/Dto/PersistedInterview.php new file mode 100644 index 000000000..84ba4213c --- /dev/null +++ b/sources/AppBundle/Event/Wordpress/Dto/PersistedInterview.php @@ -0,0 +1,13 @@ +map('array<' . Category::class . '>', Source::json($response->getContent())); } - public function persistInterview(Interview $interview, Event $event, array $speakers, array $talks): ?int + public function persistInterview(Interview $interview, Event $event, array $speakers, array $talks): PersistedInterview { $categoryId = $event->getInterviewsWordpressCategoryId(); if ($categoryId === null) { @@ -87,9 +88,10 @@ public function persistInterview(Interview $interview, Event $event, array $spea ], ]); - $id = $response->toArray()['id'] ?? null; - - return is_int($id) ? $id : null; + return $this->mapperBuilder + ->allowSuperfluousKeys() + ->mapper() + ->map(PersistedInterview::class, Source::json($response->getContent())); } private function getCategory(int $id): ?Category diff --git a/sources/AppBundle/Event/Wordpress/WordpressClient.php b/sources/AppBundle/Event/Wordpress/WordpressClient.php index cf9f5bf93..aff5e9079 100644 --- a/sources/AppBundle/Event/Wordpress/WordpressClient.php +++ b/sources/AppBundle/Event/Wordpress/WordpressClient.php @@ -9,6 +9,7 @@ use AppBundle\Event\Model\Event; use AppBundle\Event\Model\Talk; use AppBundle\Event\Wordpress\Dto\Category; +use AppBundle\Event\Wordpress\Dto\PersistedInterview; interface WordpressClient { @@ -21,5 +22,5 @@ public function listCategories(): array; * @param array $speakers * @param array $talks */ - public function persistInterview(Interview $interview, Event $event, array $speakers, array $talks): ?int; + public function persistInterview(Interview $interview, Event $event, array $speakers, array $talks): PersistedInterview; } diff --git a/templates/admin/event/interview/list.html.twig b/templates/admin/event/interview/list.html.twig index ce0cc4902..79dd37a85 100644 --- a/templates/admin/event/interview/list.html.twig +++ b/templates/admin/event/interview/list.html.twig @@ -33,6 +33,7 @@ Speaker(s) Date de publication + URL @@ -43,6 +44,16 @@ {{ row.interview.datePublication|date('d/m/Y H:i') }} + + {% if row.interview.wordpressPostSlug %} + + + + {% endif %} + diff --git a/tests/support/Wordpress/FakeWordpressClient.php b/tests/support/Wordpress/FakeWordpressClient.php index 7257f38da..aeafe99a0 100644 --- a/tests/support/Wordpress/FakeWordpressClient.php +++ b/tests/support/Wordpress/FakeWordpressClient.php @@ -7,6 +7,7 @@ use AppBundle\Event\Entity\Interview; use AppBundle\Event\Model\Event; use AppBundle\Event\Wordpress\Dto\Category; +use AppBundle\Event\Wordpress\Dto\PersistedInterview; use AppBundle\Event\Wordpress\WordpressClient; final class FakeWordpressClient implements WordpressClient @@ -18,8 +19,8 @@ public function listCategories(): array ]; } - public function persistInterview(Interview $interview, Event $event, array $speakers, array $talks): ?int + public function persistInterview(Interview $interview, Event $event, array $speakers, array $talks): PersistedInterview { - return 123; + return new PersistedInterview(123, 'super-slug'); } }