/**
  * Check if user is in the current section
  */
 private function checkSectionAccess()
 {
     /** @var User $user */
     $user = $this->security_context->getToken()->getUser();
     /** @var Section $section */
     $section = $this->sectionManager->getCurrentSection();
     if ($user instanceof User && $section instanceof Section && !$user->isSuperAdmin() && $user->getSection() != $section) {
         throw new AccessDeniedException();
     }
 }
 private function replace_keys(Emails $mail, User $is)
 {
     $mail->setBody(str_replace('is_student.prenom', $is->getPrenom(), $mail->getBody()));
     $mail->setBody(str_replace('is_student.nom', $is->getNom(), $mail->getBody()));
     $mail->setBody(str_replace('is_student.age', $is->getAge(), $mail->getBody()));
     $mail->setBody(str_replace('is_student.universite', $is->getUniversite(), $mail->getBody()));
     $mail->setBody(str_replace('is_student.email', $is->getEmail(), $mail->getBody()));
     $mail->setBody(str_replace('is_student.username', $is->getUsername(), $mail->getBody()));
     $mail->setBody(str_replace('is_student.password', $this->plainpass, $mail->getBody()));
     $mail->setBody(str_replace('is_student.nationality', $is->getNationalite(), $mail->getBody()));
     $mail->setBody(str_replace('section.name', $this->sectionManager->getCurrentSection()->getName(), $mail->getBody()));
     return $mail;
 }
 public function setSectionManager(SectionManager $manager)
 {
     $this->section = $manager->getCurrentSection();
 }