Skip to content
Snippets Groups Projects
Commit f3562b3d authored by Moreau Elise's avatar Moreau Elise
Browse files

create an action for user 's account

parent 6df9a22e
No related branches found
No related tags found
No related merge requests found
<?php
declare(strict_types=1);
namespace App\Application\Actions\User;
use Psr\Http\Message\ResponseInterface as Response;
use App\Domain\User\UserNotFoundException;
class ViewAccountAction extends UserAction
{
/**
* {@inheritdoc}
*/
protected function action(): Response
{
if (!isset($_SESSION['userId'])) {
return $this->response
->withHeader('Location', '/login')
->withStatus(302);
}
$user = $this->userRepository->find($_SESSION['userId']);
if (!isset($user)) {
throw new UserNotFoundException();
}
$this->logger->info("User of id `{$user->getId()}` was viewed.");
return $this->twig->render($this->response, "/user/user_profile.twig", ["user" => $user, "id"=> $user->getId()]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment