73 lines
2.2 KiB
PHP
73 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Entity\User;
|
|
use App\Libs\NavList;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|
|
|
class DefaultController extends AbstractController
|
|
{
|
|
|
|
public function __construct(
|
|
private readonly EntityManagerInterface $entityManager,
|
|
private readonly UserPasswordHasherInterface $userPasswordHasher,
|
|
private array $navLinks = []
|
|
) {
|
|
$this->navLinks = NavList::LIST;
|
|
}
|
|
|
|
#[Route('/dashboard', name: 'app_dashboard')]
|
|
public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response
|
|
{
|
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
|
|
|
if (!$user->getCompany()) {
|
|
return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]);
|
|
}
|
|
|
|
$this->navLinks['user_dashboard'] = 'nav-link text-white active bg-gradient-dark';
|
|
|
|
return $this->render(
|
|
'internal/dashboard.html.twig',
|
|
array_merge(
|
|
$this->navLinks,
|
|
[
|
|
'breadcrumbs' => [
|
|
'Dashboard'
|
|
],
|
|
'notifications' => $user->retrieveUnreadNotifications(),
|
|
]
|
|
)
|
|
);
|
|
}
|
|
|
|
#[Route('/profile', name: 'app_profile')]
|
|
public function profile(#[CurrentUser()] User $user): Response
|
|
{
|
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
|
|
|
$this->navLinks['profile'] = 'nav-link text-white active bg-gradient-dark';
|
|
|
|
return $this->render(
|
|
'internal/profile.html.twig',
|
|
array_merge(
|
|
$this->navLinks,
|
|
[
|
|
'breadcrumbs' => [
|
|
'Profile'
|
|
],
|
|
'notifications' => $user->retrieveUnreadNotifications(),
|
|
]
|
|
)
|
|
);
|
|
}
|
|
|
|
}
|