Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Jan 31, 2025
1 parent dec20df commit d13c9a0
Show file tree
Hide file tree
Showing 21 changed files with 138 additions and 148 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@PHP74Migration:risky' => true,
'blank_line_after_opening_tag' => true,
'concat_space' => ['spacing' => 'one'],
'no_alias_functions' => true,
Expand Down
8 changes: 4 additions & 4 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ services:
autoconfigure: true

AppBundle\Controller\Website\:
resource: '../../sources/AppBundle/Controller/Website/'
resource: '../../sources/AppBundle/Controller/Website/*'
autowire: true
autoconfigure: true

AppBundle\WebsiteBlocks:
autowire: true

AppBundle\Command\GeneralMeetupNotificationCommand:
autowire: true
autoconfigure: true
Expand Down Expand Up @@ -164,6 +161,9 @@ services:
tags:
- { name: twig.extension }

AppBundle\Twig\ViewRenderer:
autowire: true

AppBundle\Association\Form\HelpMessageExtension:
class: AppBundle\Association\Form\HelpMessageExtension
tags:
Expand Down
10 changes: 5 additions & 5 deletions sources/AppBundle/Controller/Admin/LoginAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

namespace AppBundle\Controller\Admin;

use AppBundle\WebsiteBlocks;
use AppBundle\Twig\ViewRenderer;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

class LoginAction
{
/** @var AuthenticationUtils */
private $authenticationUtils;
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;

public function __construct(
AuthenticationUtils $authenticationUtils,
WebsiteBlocks $websiteBlocks
ViewRenderer $view
) {
$this->authenticationUtils = $authenticationUtils;
$this->websiteBlocks = $websiteBlocks;
$this->view = $view;
}

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

return $this->websiteBlocks->render('admin/login.html.twig', [
return $this->view->render('admin/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
'target_path' => $targetPath,
Expand Down
14 changes: 7 additions & 7 deletions sources/AppBundle/Controller/Admin/LostPasswordAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace AppBundle\Controller\Admin;

use AppBundle\Association\UserMembership\UserService;
use AppBundle\WebsiteBlocks;
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;
Expand All @@ -15,21 +15,21 @@ class LostPasswordAction
{
/** @var FormFactoryInterface */
private $formFactory;
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;
/** @var FlashBagInterface */
private $flashBag;
/** @var UserService */
private $userPasswordService;

public function __construct(
FormFactoryInterface $formFactory,
UserService $userPasswordService,
WebsiteBlocks $websiteBlocks,
FlashBagInterface $flashBag
UserService $userPasswordService,
ViewRenderer $view,
FlashBagInterface $flashBag
) {
$this->formFactory = $formFactory;
$this->userPasswordService = $userPasswordService;
$this->websiteBlocks = $websiteBlocks;
$this->view = $view;
$this->flashBag = $flashBag;
}

Expand All @@ -46,7 +46,7 @@ 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 $this->websiteBlocks->render('admin/lost_password.html.twig', [
return $this->view->render('admin/lost_password.html.twig', [
'form' => $form->createView(),
'title' => 'Mot de passe perdu',
'page' => 'motdepasse_perdu',
Expand Down
10 changes: 5 additions & 5 deletions sources/AppBundle/Controller/Website/CmsPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

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

class CmsPageController extends Controller
{
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;

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

public function displayAction($code)
Expand All @@ -38,7 +38,7 @@ public function displayAction($code)
throw $this->createNotFoundException();
}

return $this->websiteBlocks->render('site/cms_page/display.html.twig', [
return $this->view->render('site/cms_page/display.html.twig', [
'article' => $article,
'rubrique' => $rubrique,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
use AppBundle\Association\Model\Repository\CompanyMemberRepository;
use AppBundle\Association\UserMembership\BadgesComputer;
use AppBundle\Offices\OfficesCollection;
use AppBundle\WebsiteBlocks;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\BinaryFileResponse;

class CompanyPublicProfileController extends Controller
{
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;

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

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

return $this->websiteBlocks->render('site/company_public_profile.html.twig', [
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,16 +4,16 @@

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

class CompanyPublicProfileListController extends Controller
{
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;

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

public function indexAction()
Expand All @@ -31,7 +31,7 @@ public function indexAction()
return $a <=> $b;
});

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

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

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

public function displayAction(): Response
Expand All @@ -33,7 +33,7 @@ public function displayAction(): Response
$premiereFeuille = array_shift($enfants);
$deuxiemeFeuille = array_shift($enfants);

return $this->websiteBlocks->render('site/home.html.twig', [
return $this->view->render('site/home.html.twig', [
'actualites' => $derniers_articles,
'meetups' => $this->getLatestMeetups(),
'premiere_feuille' => $premiereFeuille,
Expand Down
10 changes: 5 additions & 5 deletions sources/AppBundle/Controller/Website/HtmlSitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
use AppBundle\Event\Model\Repository\TalkRepository;
use AppBundle\Event\Model\Talk;
use AppBundle\Site\Model\Repository\ArticleRepository;
use AppBundle\WebsiteBlocks;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class HtmlSitemapController extends Controller
{
/** @var UrlGeneratorInterface */
private $urlGenerator;
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;

public function __construct(UrlGeneratorInterface $urlGenerator, WebsiteBlocks $websiteBlocks)
public function __construct(UrlGeneratorInterface $urlGenerator, ViewRenderer $view)
{
$this->urlGenerator = $urlGenerator;
$this->websiteBlocks = $websiteBlocks;
$this->view = $view;
}

public function displayAction()
{
$branche = new Branche();

return $this->websiteBlocks->render('site/sitemap.html.twig', [
return $this->view->render('site/sitemap.html.twig', [
'pages' => $this->buildLeafs($branche, Feuille::ID_FEUILLE_HEADER),
'association' => $this->buildLeafs($branche, Feuille::ID_FEUILLE_ANTENNES),
'members' => $this->members(),
Expand Down
10 changes: 5 additions & 5 deletions sources/AppBundle/Controller/Website/MeetupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

namespace AppBundle\Controller\Website;

use AppBundle\WebsiteBlocks;
use AppBundle\Twig\ViewRenderer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class MeetupsController extends Controller
{
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;

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

public function listAction(Request $request)
{
return $this->websiteBlocks->render('site/meetups/list.html.twig',[
return $this->view->render('site/meetups/list.html.twig',[
'algolia_app_id' => $this->getParameter('algolia_app_id'),
'algolia_api_key' => $this->getParameter('algolia_frontend_api_key'),
'source' => $request->get('src'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use AppBundle\Association\Model\CompanyMember;
use AppBundle\Association\Model\Repository\CompanyMemberRepository;
use AppBundle\Association\Model\User;
use AppBundle\WebsiteBlocks;
use AppBundle\Twig\ViewRenderer;
use Assert\Assertion;
use Exception;
use Symfony\Component\Form\FormFactoryInterface;
Expand All @@ -21,7 +21,7 @@ class CompanyController
{
/** @var CompanyMemberRepository */
private $companyMemberRepository;
private WebsiteBlocks $websiteBlocks;
private ViewRenderer $view;
/** @var FormFactoryInterface */
private $formFactory;
/** @var FlashBagInterface */
Expand All @@ -33,14 +33,14 @@ class CompanyController

public function __construct(
CompanyMemberRepository $companyMemberRepository,
WebsiteBlocks $websiteBlocks,
FormFactoryInterface $formFactory,
FlashBagInterface $flashBag,
UrlGeneratorInterface $urlGenerator,
Security $security
ViewRenderer $view,
FormFactoryInterface $formFactory,
FlashBagInterface $flashBag,
UrlGeneratorInterface $urlGenerator,
Security $security
) {
$this->companyMemberRepository = $companyMemberRepository;
$this->websiteBlocks = $websiteBlocks;
$this->view = $view;
$this->formFactory = $formFactory;
$this->flashBag = $flashBag;
$this->urlGenerator = $urlGenerator;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function __invoke(Request $request)
return new RedirectResponse($this->urlGenerator->generate('member_company'));
}

return $this->websiteBlocks->render('admin/association/membership/company.html.twig', [
return $this->view->render('admin/association/membership/company.html.twig', [
'title' => 'Mon adhésion entreprise',
'form' => $subscribeForm->createView(),
]);
Expand Down
Loading

0 comments on commit d13c9a0

Please sign in to comment.