src/Twig/StatExtension.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Service\StatistiquesService;
  4. use Twig\Extension\AbstractExtension;
  5. use Twig\TwigFunction;
  6. class StatExtension extends AbstractExtension
  7. {
  8. private $statService;
  9. public function __construct(StatistiquesService $statService)
  10. {
  11. $this->statService = $statService;
  12. }
  13. public function getFunctions()
  14. {
  15. return [
  16. new TwigFunction('teachers_count', [$this, 'teachers']),
  17. new TwigFunction('students_count', [$this, 'students']),
  18. new TwigFunction('rooms_count', [$this, 'rooms']),
  19. new TwigFunction('insolvents', [$this, 'insolvents']),
  20. ];
  21. }
  22. public function teachers()
  23. {
  24. return $this->statService->teachers();
  25. }
  26. public function students()
  27. {
  28. return $this->statService->students();
  29. }
  30. public function rooms()
  31. {
  32. return $this->statService->rooms();
  33. }
  34. public function insolvents()
  35. {
  36. return $this->statService->insolvents();
  37. }
  38. }