Created
March 7, 2021 09:59
-
-
Save BackEndTea/6256665f042fc499d8be58599c631d18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\Security\Core\Security; | |
use Twig\Environment; | |
class AccountPageActionV1 | |
{ | |
public function __construct( | |
private Environment $twig, | |
private Security $security | |
) {} | |
public function __invoke(): Response | |
{ | |
// Deal with things | |
return new Response( | |
$this->twig->render('account/view.html.twig', [ | |
'user' => $this->security->getUser(), | |
]) | |
); | |
} | |
} | |
class AccountPageActionV2 | |
{ | |
public function __construct( | |
private AccountPageView $view, | |
private Security $security | |
) {} | |
public function __invoke(): Response | |
{ | |
// Deal with things | |
return new Response( | |
$this->view->render($this->security->getUser()) | |
); | |
} | |
} | |
class AccountPageView | |
{ | |
public function __construct( | |
private Environment $twig, | |
private Security $security | |
) {} | |
public function render(User $user) { | |
return $this->twig->render('account/view.html.twig', [ | |
'user' => $this->security->getUser(), | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment