<?php
namespace EADPlataforma\Services\EntityServices;
use EADPlataforma\Entity\LessonModule;
use EADPlataforma\Entity\User;
use EADPlataforma\Entity\Enrollment;
use EADPlataforma\Enum\UserEnum;
use EADPlataforma\Enum\LessonModuleEnum;
use EADPlataforma\Repository\LessonModuleRepository;
use EADPlataforma\Repository\EnrollmentRepository;
use EADPlataforma\Services\GeneralService;
use EADPlataforma\Services\SchoolEntityManager;
use EADPlataforma\Services\ConfigurationService;
use EADPlataforma\Util\UserPermissionUtil;
/**
* LessonModule Service
*/
class LessonModuleService
{
/**
* @var SchoolEntityManager $em
*/
protected $em;
/**
* @var LessonModuleRepository
*/
private $repository;
/**
* @var EnrollmentRepository
*/
private $enrollmentRepository;
/**
* @var ConfigurationService
*/
private $configuration;
/**
* @var UserPermissionUtil
*/
protected $userPermissionUtil;
/**
* @var User
*/
private $user;
/**
* Constructor
*
* @param GeneralService $generalService
* @param LessonModuleRepository $LessonModuleRepository
*/
public function __construct(
GeneralService $generalService,
LessonModuleRepository $lessonModuleRepository
)
{
$this->repository = $lessonModuleRepository;
$this->em = $lessonModuleRepository->em;
$this->generalService = $generalService;
$this->configuration = $this->generalService->getService('ConfigurationService');
$this->enrollmentRepository = $this->em->getRepository(Enrollment::class);
$this->user = $this->generalService->getService('UserSessionService')->getUser();
$this->userPermissionUtil = $this->generalService->getUtil('UserPermissionUtil');
}
public function searchModule(int $moduleId): ?LessonModule
{
return $this->repository->findOneBy([
"id" => $moduleId,
"deleted" => LessonModuleEnum::ITEM_NO_DELETED
]);
}
public function getModuleIndex(
Enrollment $enrollment,
LessonModule $lessonModule,
?bool $isStudent = true
): array
{
return (array)$this->enrollmentRepository->getModuleIndexByEnrollmentNew(
$enrollment,
$lessonModule,
$isStudent
);
}
public function getModulesIndex(
Enrollment $enrollment,
?bool $isStudent = true,
?string $searchText = null
): array
{
return $this->enrollmentRepository->getModulesByEnrollmentNew(
$enrollment,
$isStudent,
$searchText
);
}
}