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
3 changes: 3 additions & 0 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ services:
Afup\Site\Association\CotisationsFactory:
autowire: true

Afup\Site\Corporate\Page:
autowire: true

Afup\Site\Forum\Facturation:
autowire: true

Expand Down
115 changes: 0 additions & 115 deletions sources/Afup/Corporate/Branche.php

This file was deleted.

32 changes: 10 additions & 22 deletions sources/Afup/Corporate/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@

namespace Afup\Site\Corporate;

use AppBundle\Site\Model\Repository\SheetRepository;
use Symfony\Component\Security\Core\User\UserInterface;

final readonly class Page
{
private _Site_Base_De_Donnees $bdd;

public function __construct()
{
$this->bdd = new _Site_Base_De_Donnees();
}
Comment on lines -11 to -16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ça fait plaisir de voir ça :D

public function __construct(
private SheetRepository $sheetRepository,
) {}

public function header($url = null, UserInterface $user = null): string
{
$branche = new Branche($this->bdd);
$url = urldecode((string) $url);
$str = '<ul>';

$feuillesEnfants = $branche->feuillesEnfants(Feuille::ID_FEUILLE_HEADER);
$feuillesEnfants = iterator_to_array($this->sheetRepository->getActiveChildrenByParentId(Feuille::ID_FEUILLE_HEADER));

if ($user instanceof UserInterface) {
$feuillesEnfants[] = [
Expand Down Expand Up @@ -72,9 +69,9 @@ public function header($url = null, UserInterface $user = null): string
}

if (false === $isCurrent) {
$enfants = $branche->feuillesEnfants($feuille['id']);
$enfants = $this->sheetRepository->getActiveChildrenByParentId($feuille['id']);
foreach ($enfants as $feuilleEnfant) {
foreach ($branche->feuillesEnfants($feuilleEnfant['id']) as $feuillesEnfant2) {
foreach ($this->sheetRepository->getActiveChildrenByParentId($feuilleEnfant['id']) as $feuillesEnfant2) {
if (str_contains($url, (string) $feuillesEnfant2['lien'])) {
$isCurrent = true;
}
Expand All @@ -99,23 +96,14 @@ public function header($url = null, UserInterface $user = null): string
*/
public function footer(): array
{
$branche = new Branche($this->bdd);

$footerColumns = [];
foreach ($branche->feuillesEnfants(Feuille::ID_FEUILLE_FOOTER) as $feuilleColonne) {
foreach ($this->sheetRepository->getActiveChildrenByParentId(Feuille::ID_FEUILLE_FOOTER) as $feuilleColonne) {
$footerColumns[] = [
'nom' => $branche->getNom($feuilleColonne['id']),
'items' => $branche->feuillesEnfants($feuilleColonne['id']),
'nom' => $feuilleColonne['nom'],
'items' => $this->sheetRepository->getActiveChildrenByParentId($feuilleColonne['id']),
];
}

return $footerColumns;
}

public function getRightColumn(): Branche
{
$branche = new Branche($this->bdd);
$branche->navigation_avec_image(true);
return $branche;
}
}
6 changes: 3 additions & 3 deletions sources/AppBundle/Controller/Website/Global/HomeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace AppBundle\Controller\Website\Global;

use Afup\Site\Corporate\Branche;
use Afup\Site\Corporate\Feuille;
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
use Algolia\AlgoliaSearch\SearchClient;
use AppBundle\Event\Model\Meetup;
use AppBundle\Event\Model\Repository\TalkRepository;
use AppBundle\Event\Model\Talk;
use AppBundle\Site\Model\Repository\ArticleRepository;
use AppBundle\Site\Model\Repository\SheetRepository;
use AppBundle\Twig\ViewRenderer;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Cache\InvalidArgumentException;
Expand All @@ -33,14 +33,14 @@ public function __construct(
#[Autowire('%home_algolia_enabled%')]
private readonly bool $homeAlgoliaEnabled,
private readonly ArticleRepository $articleRepository,
private readonly SheetRepository $sheetRepository,
) {}

public function __invoke(): Response
{
$derniers_articles = $this->articleRepository->findListForHome();

$branche = new Branche();
$enfants = $branche->feuillesEnfants(Feuille::ID_FEUILLE_COLONNE_DROITE);
$enfants = iterator_to_array($this->sheetRepository->getActiveChildrenByParentId(Feuille::ID_FEUILLE_COLONNE_DROITE));

$premiereFeuille = array_shift($enfants);
$deuxiemeFeuille = array_shift($enfants);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace AppBundle\Controller\Website\Global;

use Afup\Site\Corporate\Branche;
use Afup\Site\Corporate\Feuille;
use AppBundle\Association\Model\Repository\CompanyMemberRepository;
use AppBundle\Event\Model\Repository\TalkRepository;
use AppBundle\Event\Model\Talk;
use AppBundle\Site\Model\Repository\ArticleRepository;
use AppBundle\Site\Model\Repository\SheetRepository;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -21,24 +21,23 @@ public function __construct(
private readonly CompanyMemberRepository $companyMemberRepository,
private readonly ArticleRepository $articleRepository,
private readonly TalkRepository $talkRepository,
private readonly SheetRepository $sheetRepository,
) {}

public function __invoke(): Response
{
$branche = new Branche();

return $this->view->render('site/sitemap.html.twig', [
'pages' => $this->buildLeafs($branche, Feuille::ID_FEUILLE_HEADER),
'association' => $this->buildLeafs($branche, Feuille::ID_FEUILLE_ANTENNES),
'pages' => $this->buildLeafs(Feuille::ID_FEUILLE_HEADER),
'association' => $this->buildLeafs(Feuille::ID_FEUILLE_ANTENNES),
'members' => $this->members(),
'news' => $this->news(),
'talks' => $this->talks(),
]);
}

private function buildLeafs(Branche $branche, int $id): array
private function buildLeafs(int $id): array
{
$leafs = $branche->feuillesEnfants($id);
$leafs = $this->sheetRepository->getActiveChildrenByParentId($id);

$pages = [];
foreach ($leafs as $leaf) {
Expand Down
13 changes: 8 additions & 5 deletions sources/AppBundle/Controller/Website/SecondaryMenuController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@

namespace AppBundle\Controller\Website;

use Afup\Site\Corporate\Branche;
use AppBundle\Site\Model\Repository\SheetRepository;
use CCMBenchmark\Ting\Repository\CollectionInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

class SecondaryMenuController extends AbstractController
{
public function __construct(private readonly RequestStack $requestStack) {}
public function __construct(
private readonly RequestStack $requestStack,
private readonly SheetRepository $sheetRepository,
) {}

public function display(Request $request): Response
{
$branche = new Branche();
$menu = $branche->feuillesEnfants($request->get('feuille_id'));
$menu = $this->sheetRepository->getActiveChildrenByParentId($request->get('feuille_id'));

return $this->render(
'site/secondary_menu.html.twig',
Expand All @@ -30,7 +33,7 @@ public function display(Request $request): Response
/**
* @return mixed[]
*/
protected function prepareMenu(Request $masterRequest, array $menu): array
protected function prepareMenu(Request $masterRequest, CollectionInterface $menu): array
{
$preparedMenu = [];

Expand Down
29 changes: 29 additions & 0 deletions sources/AppBundle/Site/Model/Repository/SheetRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace AppBundle\Site\Model\Repository;

use AppBundle\Site\Model\Sheet;
use Aura\SqlQuery\Common\SelectInterface;
use CCMBenchmark\Ting\Exception;
use CCMBenchmark\Ting\Query\QueryException;
use CCMBenchmark\Ting\Repository\CollectionInterface;
Expand Down Expand Up @@ -49,6 +50,34 @@ public function getAllSheets(string $ordre = 'date', string $direction = 'desc',
return $query->query($this->getCollection(new HydratorArray()));
}

public function getActiveChildrenByParentId(int $parentId): CollectionInterface
{
$queryBuilder = $this->getActiveChildrenByParentIdBuilder();

$query = $this->getPreparedQuery($queryBuilder->getStatement())->setParams(['parentId' => $parentId]);
return $query->query($this->getCollection(new HydratorArray()));
}

public function getActiveChildrenByParentIdOrderedByPostion(int $parentId): CollectionInterface
{
$queryBuilder = $this->getActiveChildrenByParentIdBuilder();
$queryBuilder->orderBy(['position', 'asc']);

$query = $this->getPreparedQuery($queryBuilder->getStatement())->setParams(['parentId' => $parentId]);
return $query->query($this->getCollection(new HydratorArray()));
}

private function getActiveChildrenByParentIdBuilder(): SelectInterface
{
/**
* @var SelectInterface $queryBuilder
*/
$queryBuilder = $this->getQueryBuilder(self::QUERY_SELECT);
$queryBuilder->cols(['*'])->from('afup_site_feuille')->where('id_parent = :parentId')->where('etat = 1');

return $queryBuilder;
}

/**
* @inheritDoc
*/
Expand Down
7 changes: 3 additions & 4 deletions sources/AppBundle/Subscriber/SitemapXmlSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace AppBundle\Subscriber;

use Afup\Site\Corporate\Branche;
use Afup\Site\Corporate\Feuille;
use AppBundle\Association\Model\CompanyMember;
use AppBundle\Association\Model\Repository\CompanyMemberRepository;
Expand All @@ -17,6 +16,7 @@
use AppBundle\Event\Model\Talk;
use AppBundle\Site\Model\Article;
use AppBundle\Site\Model\Repository\ArticleRepository;
use AppBundle\Site\Model\Repository\SheetRepository;
use Presta\SitemapBundle\Event\SitemapPopulateEvent;
use Presta\SitemapBundle\Service\UrlContainerInterface;
use Presta\SitemapBundle\Sitemap\Url\GoogleVideo;
Expand All @@ -34,6 +34,7 @@ public function __construct(
private readonly EventRepository $eventRepository,
private readonly ArticleRepository $articleRepository,
private readonly CompanyMemberRepository $companyMemberRepository,
private readonly SheetRepository $sheetRepository,
) {}

public static function getSubscribedEvents(): array
Expand Down Expand Up @@ -194,9 +195,7 @@ private function registerDefaultPages(UrlContainerInterface $urls): void

private function fromFeuilleId(int $id, UrlContainerInterface $urls): void
{
$branche = new Branche();

$leafs = $branche->feuillesEnfants($id);
$leafs = $this->sheetRepository->getActiveChildrenByParentId($id);
foreach ($leafs as $leaf) {
if (!$leaf['lien'] || !str_starts_with((string) $leaf['lien'], 'http')) {
continue;
Expand Down
Loading