-use Symfony\Component\Routing\RequestContext;
-use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
-use Rapsys\AirBundle\Entity\Slot;
-use Rapsys\AirBundle\Entity\Session;
-use Rapsys\AirBundle\Entity\Location;
-use Rapsys\AirBundle\Entity\User;
-use Rapsys\AirBundle\Entity\Snippet;
-
-class UserController extends DefaultController {
- /**
- * List all users
- *
- * @desc Display all user with a group listed as users
- *
- * @param Request $request The request instance
- *
- * @return Response The rendered view
- */
- public function index(Request $request): Response {
- //Fetch doctrine
- $doctrine = $this->getDoctrine();
-
- //Set section
- $section = $this->translator->trans('Libre Air users');
-
- //Set description
- $this->context['description'] = $this->translator->trans('Libre Air user list');
-
- //Set keywords
- $this->context['keywords'] = [
- $this->translator->trans('users'),
- $this->translator->trans('user list'),
- $this->translator->trans('listing'),
- $this->translator->trans('Libre Air')
- ];
-
- //Set title
- $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
-
- //Fetch users
- $users = $doctrine->getRepository(User::class)->findUserGroupedByTranslatedGroup($this->translator);
-
- //Compute period
- $period = new \DatePeriod(
- //Start from first monday of week
- new \DateTime('Monday this week'),
- //Iterate on each day
- new \DateInterval('P1D'),
- //End with next sunday and 4 weeks
- new \DateTime(
- $this->isGranted('IS_AUTHENTICATED_REMEMBERED')?'Monday this week + 3 week':'Monday this week + 2 week'
- )
- );
-
- //Without admin role
- if (!$this->isGranted('ROLE_ADMIN')) {
- //Remove users
- unset($users[$this->translator->trans('User')]);
- }