- //Set section
- $section = $user->getPseudonym();
-
- //Set title
- $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
-
- //Set description
- $this->context['description'] = $this->translator->trans('%pseudonym% outdoor Argentine Tango session calendar', [ '%pseudonym%' => $user->getPseudonym() ]);
-
- //Set keywords
- $this->context['keywords'] = [
- $user->getPseudonym(),
- $this->translator->trans('outdoor'),
- $this->translator->trans('Argentine Tango'),
- $this->translator->trans('calendar')
- ];
-
- //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'
- )
- );
-
- //Fetch calendar
- //TODO: highlight with current session route parameter
- $calendar = $doctrine->getRepository(Session::class)->fetchUserCalendarByDatePeriod($this->translator, $period, $isGuest?$id:null, $request->get('session'), $request->getLocale());
+ //With admin
+ if ($this->isGranted('ROLE_ADMIN')) {
+ //With pseudonym and without slug
+ if (!empty($pseudonym = $user->getPseudonym()) && empty($user->getSlug())) {
+ //Preset slug
+ $user->setSlug($slugger->slug($pseudonym));
+ }
+ }