Skip to content

Commit

Permalink
afup#386 sitemap add members
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Nov 27, 2024
1 parent ead87f3 commit f9d0a4e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ services:
tags:
- {name: form.type}

AppBundle\Subscriber\TalksAndNewsSitemapSubscriber:
AppBundle\Subscriber\SitemapXmlSubscriber:
arguments:
- "@router"
- "@ting"
Expand Down
11 changes: 11 additions & 0 deletions db/seeds/Feuilles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -133,6 +140,10 @@ private function getFooter()
'nom' => 'Actualités',
'lien' => '/news',
],
[
'nom' => 'Plan du site',
'lien' => '/plan-du-site',
],
]
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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',
Expand All @@ -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)
Expand Down Expand Up @@ -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'
);
}
}
}

0 comments on commit f9d0a4e

Please sign in to comment.