src/Service/SchoolYearService.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use App\Repository\SchoolYearRepository;
  4. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Service;
  6. /**
  7.  * @Service("school_year_service")
  8.  */
  9. class SchoolYearService
  10. {
  11.     private SchoolYearRepository $scRepo;
  12.     private SessionInterface $session;
  13.     public function __constructSchoolYearRepository $scRepoSessionInterface $session)
  14.     {
  15.         $this->scRepo $scRepo;
  16.         $this->session $session;
  17.     }
  18.     public function years()
  19.     {
  20.        
  21.         return $this->scRepo->findAll(array('id' => 'ASC'));
  22.     }
  23.     public function sessionYearByCode()
  24.     {   
  25.        
  26.         return ($this->session->has('session_school_year') && ($this->session->get('session_school_year')!= null)) ? $this->scRepo->findOneBy(array("code" => $this->session->get('session_school_year')))  : $this->scRepo->findOneBy(array("activated" => true));
  27.     }
  28.     public function sessionYearById()
  29.     {
  30.         return ($this->session->has('session_school_year') && ($this->session->get('session_school_year')!= null)) ? $this->scRepo->findOneBy(array("id" => $this->session->get('session_school_year')))  : $this->scRepo->findOneBy(array("activated" => true));
  31.     }
  32.     public function enabledYear($id)
  33.     {
  34.         return $this->scRepo->findOneBy(array('id' => $id));
  35.     }
  36.     
  37.     
  38.     public function updateEnabledSchoolYear()
  39.     {
  40.         return $this->scRepo->findAll(array('id' => 'ASC'));
  41.     }
  42.    
  43. }