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 __construct( SchoolYearRepository $scRepo, SessionInterface $session)
  14. {
  15. $this->scRepo = $scRepo;
  16. $this->session = $session;
  17. }
  18. public function years()
  19. {
  20. return $this->scRepo->findAll(array('id' => 'ASC'));
  21. }
  22. public function sessionYearByCode()
  23. {
  24. 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));
  25. }
  26. public function sessionYearById()
  27. {
  28. 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));
  29. }
  30. public function enabledYear($id)
  31. {
  32. return $this->scRepo->findOneBy(array('id' => $id));
  33. }
  34. public function updateEnabledSchoolYear()
  35. {
  36. return $this->scRepo->findAll(array('id' => 'ASC'));
  37. }
  38. }