File: /var/www/dvpis2025/dvpis.kaunokolegija.lt/src/Service/ProcessDatesValidation.php
<?php
namespace App\Service;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\ProcessDates;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
readonly class ProcessDatesValidation
{
public function __construct(
private EntityManagerInterface $em,
private AuthorizationCheckerInterface $authorizationChecker,
) {
}
public function isOnlyView(): bool
{
if (
$this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT')
|| $this->isActivePlan()
|| $this->isActiveProcessPlan()
) {
return false;
}
// if ($this->isActivePlan() && !$this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT')) {
// return false;
// }
// if ($this->isActiveProcessPlan() && !$this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT')) {
// return false;
// }
return true;
}
public function isActivePlan(): bool
{
return $this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT') || $this->em->getRepository(ProcessDates::class)->getIsActivePlan();
}
public function isActiveProcessPlan(): bool
{
return $this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT') || $this->em->getRepository(ProcessDates::class)->getIsActiveProcessPlan();
}
public function isActiveFact(): bool
{
return $this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT') || $this->em->getRepository(ProcessDates::class)->getIsActiveFact();
}
public function isActiveLecturerWorkTime(): bool
{
return $this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT') || $this->em->getRepository(ProcessDates::class)->getIsActiveLecturerWorkTime();
}
public function isActiveLecturerPoll(): bool
{
return $this->authorizationChecker->isGranted('ROLE_STUDY_DEPARTMENT') || $this->em->getRepository(ProcessDates::class)->getIsActiveLecturerPoll();
}
}