HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
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();
    }
}