From f9d0a4ed0df024413eb442b54bfab9f0aabd50cf Mon Sep 17 00:00:00 2001 From: Stakovicz Date: Wed, 27 Nov 2024 17:32:02 +0100 Subject: [PATCH] afup#386 sitemap add members --- app/config/services.yml | 2 +- db/seeds/Feuilles.php | 11 +++++++ ...ubscriber.php => SitemapXmlSubscriber.php} | 31 +++++++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) rename sources/AppBundle/Subscriber/{TalksAndNewsSitemapSubscriber.php => SitemapXmlSubscriber.php} (70%) diff --git a/app/config/services.yml b/app/config/services.yml index 0fb952c1d..d8e9366ea 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -640,7 +640,7 @@ services: tags: - {name: form.type} - AppBundle\Subscriber\TalksAndNewsSitemapSubscriber: + AppBundle\Subscriber\SitemapXmlSubscriber: arguments: - "@router" - "@ting" diff --git a/db/seeds/Feuilles.php b/db/seeds/Feuilles.php index 33006d3a9..61f4fc541 100644 --- a/db/seeds/Feuilles.php +++ b/db/seeds/Feuilles.php @@ -106,6 +106,13 @@ public function run() 'lien' => '/association/antennes', 'etat' => 1, ], + [ + 'id_parent' => Feuille::ID_FEUILLE_HEADER, + 'nom' => 'Plan du site', + 'lien' => '/plan-du-site', + 'date' => 1732710484, + 'etat' => 1, + ], ]; $data = array_merge($data, $this->prepareFeuilles($this->getFooter(), Feuille::ID_FEUILLE_FOOTER)); @@ -133,6 +140,10 @@ private function getFooter() 'nom' => 'Actualités', 'lien' => '/news', ], + [ + 'nom' => 'Plan du site', + 'lien' => '/plan-du-site', + ], ] ], [ diff --git a/sources/AppBundle/Subscriber/TalksAndNewsSitemapSubscriber.php b/sources/AppBundle/Subscriber/SitemapXmlSubscriber.php similarity index 70% rename from sources/AppBundle/Subscriber/TalksAndNewsSitemapSubscriber.php rename to sources/AppBundle/Subscriber/SitemapXmlSubscriber.php index 0ce2ca21b..53593751e 100644 --- a/sources/AppBundle/Subscriber/TalksAndNewsSitemapSubscriber.php +++ b/sources/AppBundle/Subscriber/SitemapXmlSubscriber.php @@ -2,6 +2,7 @@ namespace AppBundle\Subscriber; +use AppBundle\Association\Model\Repository\CompanyMemberRepository; use AppBundle\Event\Model\Repository\TalkRepository; use AppBundle\Event\Model\Talk; use AppBundle\Site\Model\Article; @@ -13,7 +14,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -class TalksAndNewsSitemapSubscriber implements EventSubscriberInterface +class SitemapXmlSubscriber implements EventSubscriberInterface { /** @var RepositoryFactory */ private $ting; @@ -27,7 +28,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator, RepositoryFacto $this->ting = $ting; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ SitemapPopulateEvent::ON_SITEMAP_POPULATE => 'populate', @@ -38,6 +39,7 @@ public function populate(SitemapPopulateEvent $event) { $this->registerTalksUrls($event->getUrlContainer()); $this->registerNewsUrls($event->getUrlContainer()); + $this->registerMembers($event->getUrlContainer()); } public function registerTalksUrls(UrlContainerInterface $urls) @@ -81,4 +83,29 @@ public function registerNewsUrls(UrlContainerInterface $urls) ); } } + + private function registerMembers(UrlContainerInterface $urls) + { + /** + * @var CompanyMemberRepository $companyRepository + */ + $companyRepository = $this->ting->get(CompanyMemberRepository::class); + $displayableCompanies = $companyRepository->findDisplayableCompanies(); + + foreach ($displayableCompanies as $member) { + $urls->addUrl( + new UrlConcrete( + $this->urlGenerator->generate( + 'company_public_profile', + [ + 'id' => $member->getId(), + 'slug' => $member->getSlug(), + ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ), + 'members' + ); + } + } }