Skip to content

Commit

Permalink
On enlève SiteBaseController et tout ce qui va avec (#1605)
Browse files Browse the repository at this point in the history
* On enlève SiteBaseController et tout ce qui va avec
  • Loading branch information
stakovicz authored Feb 3, 2025
1 parent b3e08ae commit 991c22c
Show file tree
Hide file tree
Showing 28 changed files with 360 additions and 408 deletions.
8 changes: 3 additions & 5 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ services:
tags:
- { name: twig.extension }

AppBundle\Twig\ViewRenderer:
autowire: true

AppBundle\Association\Form\HelpMessageExtension:
class: AppBundle\Association\Form\HelpMessageExtension
tags:
Expand All @@ -171,11 +174,6 @@ services:
tags:
- { name: kernel.event_listener, event: kernel.request, priority: 100 }

AppBundle\Listener\LegacySiteListener:
autowire: true
tags:
- { name: kernel.event_listener, event: kernel.controller, priority: 100 }

AppBundle\Event\Model\Repository\SpeakerRepository:
class: AppBundle\Event\Model\Repository\SpeakerRepository
factory: ["@ting", get]
Expand Down
1 change: 0 additions & 1 deletion htdocs/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
$kernel = new AppKernel('prod', false);
}

$kernel->loadClassCache();
$request = Request::createFromGlobals();

$proxies = [
Expand Down
7 changes: 0 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,3 @@ parameters:
stubFiles:
- tests/stubs/Ting/Repository/Repository.php.stub
- tests/stubs/Ting/Repository/RepositoryFactory.php.stub

ignoreErrors:
-
message: '#^Method AppBundle\\Controller\\Website\\SiteBaseController\:\:render\(\) overrides @final method Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller\:\:render\(\)\.$#'
identifier: method.parentMethodFinalByPhpDoc
count: 1
path: sources/AppBundle/Controller/Website/SiteBaseController.php
19 changes: 6 additions & 13 deletions sources/AppBundle/Controller/Admin/LoginAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,22 @@

namespace AppBundle\Controller\Admin;

use AppBundle\Controller\Website\BlocksHandler;
use AppBundle\Twig\ViewRenderer;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Twig\Environment;

class LoginAction
{
/** @var AuthenticationUtils */
private $authenticationUtils;
/** @var BlocksHandler */
private $blocksHandler;
/** @var Environment */
private $twig;
private ViewRenderer $view;

public function __construct(
AuthenticationUtils $authenticationUtils,
BlocksHandler $blocksHandler,
Environment $twig
ViewRenderer $view
) {
$this->authenticationUtils = $authenticationUtils;
$this->blocksHandler = $blocksHandler;
$this->twig = $twig;
$this->view = $view;
}

public function __invoke(Request $request)
Expand All @@ -40,13 +33,13 @@ public function __invoke(Request $request)
$noDomain = parse_url($targetUri, PHP_URL_HOST) === null;
$targetPath = $targetUri !== $actualUrl && $noDomain ? $targetUri : null;

return new Response($this->twig->render('admin/login.html.twig', [
return $this->view->render('admin/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
'target_path' => $targetPath,
'title' => 'Connexion',
'page' => 'connexion',
'class' => 'panel-page',
] + $this->blocksHandler->getDefaultBlocks()));
]);
}
}
31 changes: 12 additions & 19 deletions sources/AppBundle/Controller/Admin/LostPasswordAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,33 @@
namespace AppBundle\Controller\Admin;

use AppBundle\Association\UserMembership\UserService;
use AppBundle\Controller\Website\BlocksHandler;
use AppBundle\Twig\ViewRenderer;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Twig\Environment;

class LostPasswordAction
{
/** @var FormFactoryInterface */
private $formFactory;
/** @var BlocksHandler */
private $blocksHandler;
/** @var Environment */
private $twig;
private ViewRenderer $view;
/** @var FlashBagInterface */
private $flashBag;
/** @var UserService */
private $userPasswordService;

public function __construct(
FormFactoryInterface $formFactory,
UserService $userPasswordService,
BlocksHandler $blocksHandler,
Environment $twig,
FlashBagInterface $flashBag
UserService $userPasswordService,
ViewRenderer $view,
FlashBagInterface $flashBag
) {
$this->formFactory = $formFactory;
$this->userPasswordService = $userPasswordService;
$this->blocksHandler = $blocksHandler;
$this->twig = $twig;
$this->view = $view;
$this->flashBag = $flashBag;
}

Expand All @@ -53,11 +46,11 @@ public function __invoke(Request $request)
$this->flashBag->add('notice', 'Votre demande a été prise en compte. Si un compte correspond à cet email vous recevez un nouveau mot de passe rapidement.');
}

return new Response($this->twig->render('admin/lost_password.html.twig', [
'form' => $form->createView(),
'title' => 'Mot de passe perdu',
'page' => 'motdepasse_perdu',
'class' => 'panel-page',
] + $this->blocksHandler->getDefaultBlocks()));
return $this->view->render('admin/lost_password.html.twig', [
'form' => $form->createView(),
'title' => 'Mot de passe perdu',
'page' => 'motdepasse_perdu',
'class' => 'panel-page',
]);
}
}
33 changes: 0 additions & 33 deletions sources/AppBundle/Controller/Website/BlocksHandler.php

This file was deleted.

22 changes: 14 additions & 8 deletions sources/AppBundle/Controller/Website/CmsPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@

use Afup\Site\Corporate\Article;
use Afup\Site\Corporate\Rubrique;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class CmsPageController extends SiteBaseController
class CmsPageController extends Controller
{
private ViewRenderer $view;

public function __construct(ViewRenderer $view)
{
$this->view = $view;
}

public function displayAction($code)
{
$articleRepository = new Article(null, $GLOBALS['AFUP_DB']);
Expand All @@ -29,13 +38,10 @@ public function displayAction($code)
throw $this->createNotFoundException();
}

return $this->render(
':site:cms_page/display.html.twig',
[
'article' => $article,
'rubrique' => $rubrique,
]
);
return $this->view->render('site/cms_page/display.html.twig', [
'article' => $article,
'rubrique' => $rubrique,
]);
}

protected function isRubriqueAllowed($rubrique)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@
use AppBundle\Association\Model\Repository\CompanyMemberRepository;
use AppBundle\Association\UserMembership\BadgesComputer;
use AppBundle\Offices\OfficesCollection;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\BinaryFileResponse;

class CompanyPublicProfileController extends SiteBaseController
class CompanyPublicProfileController extends Controller
{
private ViewRenderer $view;

public function __construct(ViewRenderer $view)
{
$this->view = $view;
}

public function indexAction($id, $slug)
{
$companyMember = $this->checkAndGetCompanyMember($id, $slug);

return $this->render(
':site:company_public_profile.html.twig',
[
'company_member' => $companyMember,
'offices' => $this->getRelatedAfupOffices($companyMember),
'badges' => $this->get(BadgesComputer::class)->getCompanyBadges($companyMember),
]
);
return $this->view->render('site/company_public_profile.html.twig', [
'company_member' => $companyMember,
'offices' => $this->getRelatedAfupOffices($companyMember),
'badges' => $this->get(BadgesComputer::class)->getCompanyBadges($companyMember),
]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@

use AppBundle\Association\Model\CompanyMember;
use AppBundle\Association\Model\Repository\CompanyMemberRepository;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class CompanyPublicProfileListController extends SiteBaseController
class CompanyPublicProfileListController extends Controller
{
private ViewRenderer $view;

public function __construct(ViewRenderer $view)
{
$this->view = $view;
}

public function indexAction()
{
/**
Expand All @@ -22,11 +31,8 @@ public function indexAction()
return $a <=> $b;
});

return $this->render(
':site:company_public_profile_list.html.twig',
[
'company_member_list' => $displayableCompanies,
]
);
return $this->view->render(':site:company_public_profile_list.html.twig', [
'company_member_list' => $displayableCompanies,
]);
}
}
38 changes: 21 additions & 17 deletions sources/AppBundle/Controller/Website/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,40 @@
use Afup\Site\Corporate\Feuille;
use AppBundle\Event\Model\Repository\TalkRepository;
use AppBundle\Event\Model\Talk;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class HomeController extends SiteBaseController
class HomeController extends Controller
{
const MAX_ARTICLES = 5;
const MAX_MEETUPS = 10;
public const MAX_ARTICLES = 5;
public const MAX_MEETUPS = 10;
private ViewRenderer $view;

public function displayAction()
public function __construct(ViewRenderer $view)
{
$afupBdd = $GLOBALS['AFUP_DB'];
$this->view = $view;
}

public function displayAction(): Response
{
$articles = new Articles();
$derniers_articles = $articles->chargerDerniersAjouts(self::MAX_ARTICLES);

$branche = new Branche($afupBdd);
$branche = new Branche();
$enfants = $branche->feuillesEnfants(Feuille::ID_FEUILLE_COLONNE_DROITE);

$premiereFeuille = array_shift($enfants);
$deuxiemeFeuille = array_shift($enfants);

return $this->render(
':site:home.html.twig',
[
'actualites' => $derniers_articles,
'meetups' => $this->getLatestMeetups(),
'premiere_feuille' => $premiereFeuille,
'deuxieme_feuille' => $deuxiemeFeuille,
'autres_feuilles' => $enfants,
'talk' => $deuxiemeFeuille ?? $this->getTalkOfTheDay(),
]
);
return $this->view->render('site/home.html.twig', [
'actualites' => $derniers_articles,
'meetups' => $this->getLatestMeetups(),
'premiere_feuille' => $premiereFeuille,
'deuxieme_feuille' => $deuxiemeFeuille,
'autres_feuilles' => $enfants,
'talk' => $deuxiemeFeuille ?? $this->getTalkOfTheDay(),
]);
}

/**
Expand Down
Loading

0 comments on commit 991c22c

Please sign in to comment.