src/Services/EntityServices/LessonModuleService.php line 84

Open in your IDE?
  1. <?php
  2. namespace EADPlataforma\Services\EntityServices;
  3. use EADPlataforma\Entity\LessonModule;
  4. use EADPlataforma\Entity\User;
  5. use EADPlataforma\Entity\Enrollment;
  6. use EADPlataforma\Enum\UserEnum;
  7. use EADPlataforma\Enum\LessonModuleEnum;
  8. use EADPlataforma\Repository\LessonModuleRepository;
  9. use EADPlataforma\Repository\EnrollmentRepository;
  10. use EADPlataforma\Services\GeneralService;
  11. use EADPlataforma\Services\SchoolEntityManager;
  12. use EADPlataforma\Services\ConfigurationService;
  13. use EADPlataforma\Util\UserPermissionUtil;
  14. /**
  15.  * LessonModule Service
  16.  */
  17. class LessonModuleService
  18. {
  19.     /**
  20.      * @var SchoolEntityManager $em
  21.      */
  22.     protected $em;
  23.     /**
  24.      * @var LessonModuleRepository
  25.      */
  26.     private $repository;
  27.     /**
  28.      * @var EnrollmentRepository
  29.      */
  30.     private $enrollmentRepository;
  31.     /**
  32.      * @var ConfigurationService
  33.      */
  34.     private $configuration;
  35.     /**
  36.      * @var UserPermissionUtil
  37.      */
  38.     protected $userPermissionUtil;
  39.     /**
  40.      * @var User
  41.      */
  42.     private $user;
  43.     /**
  44.      * Constructor
  45.      *
  46.      * @param GeneralService $generalService
  47.      * @param LessonModuleRepository $LessonModuleRepository
  48.      */
  49.     public function __construct(
  50.         GeneralService $generalService
  51.         LessonModuleRepository $lessonModuleRepository
  52.     )
  53.     {
  54.         $this->repository $lessonModuleRepository;
  55.         $this->em $lessonModuleRepository->em;
  56.         $this->generalService $generalService;
  57.         $this->configuration $this->generalService->getService('ConfigurationService');
  58.         $this->enrollmentRepository $this->em->getRepository(Enrollment::class);
  59.         $this->user $this->generalService->getService('UserSessionService')->getUser();
  60.         $this->userPermissionUtil $this->generalService->getUtil('UserPermissionUtil');
  61.     }
  62.     public function searchModule(int $moduleId): ?LessonModule
  63.     {
  64.         return $this->repository->findOneBy([
  65.             "id" => $moduleId,
  66.             "deleted" => LessonModuleEnum::ITEM_NO_DELETED
  67.         ]);
  68.     }
  69.     public function getModuleIndex(
  70.         Enrollment $enrollment
  71.         LessonModule $lessonModule
  72.         ?bool $isStudent true
  73.     ): array
  74.     {
  75.         return (array)$this->enrollmentRepository->getModuleIndexByEnrollmentNew(
  76.             $enrollment,
  77.             $lessonModule,
  78.             $isStudent
  79.         );
  80.     }
  81.     public function getModulesIndex(
  82.         Enrollment $enrollment
  83.         ?bool $isStudent true,
  84.         ?string $searchText null
  85.     ): array
  86.     {
  87.         return $this->enrollmentRepository->getModulesByEnrollmentNew(
  88.             $enrollment,
  89.             $isStudent,
  90.             $searchText
  91.         );
  92.     }
  93. }