2024-11-28 11:37:56 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use App\Entity\User;
|
2024-11-29 21:46:33 -05:00
|
|
|
use App\Form\UserFormType;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
2024-11-28 11:37:56 -05:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2024-11-29 21:46:33 -05:00
|
|
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
2024-11-28 11:37:56 -05:00
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
|
|
|
|
|
|
|
class DefaultController extends AbstractController
|
|
|
|
{
|
2024-11-29 21:46:33 -05:00
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
private readonly EntityManagerInterface $entityManager,
|
|
|
|
private readonly UserPasswordHasherInterface $userPasswordHasher,
|
|
|
|
private array $navLinks = []
|
|
|
|
) {
|
|
|
|
$this->navLinks = [
|
|
|
|
'admin_dashboard' => 'nav-link text-dark',
|
|
|
|
'user_dashboard' => 'nav-link text-dark',
|
|
|
|
'profile' => 'nav-link text-dark',
|
|
|
|
'user_list' => 'nav-link text-dark',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-11-28 11:37:56 -05:00
|
|
|
#[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]);
|
|
|
|
}
|
|
|
|
|
2024-11-29 21:46:33 -05:00
|
|
|
$this->navLinks['user_dashboard'] = 'nav-link text-white active bg-gradient-dark';
|
|
|
|
|
2024-11-28 11:37:56 -05:00
|
|
|
return $this->render(
|
|
|
|
'internal/dashboard.html.twig',
|
2024-11-29 21:46:33 -05:00
|
|
|
array_merge(
|
|
|
|
$this->navLinks,
|
|
|
|
[
|
|
|
|
'breadcrumbs' => [
|
|
|
|
'Dashboard'
|
|
|
|
],
|
|
|
|
'notifications' => $user->retrieveUnreadNotifications(),
|
|
|
|
]
|
|
|
|
)
|
2024-11-28 11:37:56 -05:00
|
|
|
);
|
|
|
|
}
|
2024-11-29 21:46:33 -05:00
|
|
|
|
|
|
|
#[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(),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-11-28 11:37:56 -05:00
|
|
|
}
|