<commit_before><?php

namespace App\Security\Voter;

use App\Cnst\AccessCnst;
use App\Cnst\RoleCnst;
use App\Service\ConfigService;
use App\Service\PageParamsService;
use App\Service\SessionUserService;
use App\Service\SystemsService;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;

class ElandRoleVoter extends Voter
{
    protected SessionUserService $su;
    protected PageParamsService $pp;
    protected RequestStack $request_stack;
    protected string $system;
    protected string $org_system;
    protected ConfigService $config_service;
    protected SystemsService $systems_service;

    public function __construct(
        SessionUserService $su,
        PageParamsService $pp,
        ConfigService $config_service,
        SystemsService $systems_service
    )
    {
        $this->su = $su;
        $this->pp = $pp;
        $this->config_service = $config_service;
        $this->systems_service = $systems_service;
    }

    protected function supports($attribute, $subject):bool
    {
        if ($this->pp->schema() === '')
        {
            return false;
        }

        return isset(RoleCnst::SHORT[$attribute]);
    }

    protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        if ($attribute === 'guest' || $attribute === 'user')
        {
            $schema = $this->pp->schema();

            if ($schema === '')
            {
                return false;
            }

            if ($this->config_service->get('maintenance', $schema))
            {
                return false;
            }

            if ($attribute === 'guest'
                && !$this->config_service->get_intersystem_en($schema))
            {
                return false;
            }
        }

        return AccessCnst::ACCESS[$this->su->role()][$attribute] ?? false;
    }
}<commit_msg>guest voter<commit_after><?php

namespace App\Security\Voter;

use App\Cnst\AccessCnst;
use App\Cnst\RoleCnst;
use App\Service\ConfigService;
use App\Service\IntersystemsService;
use App\Service\PageParamsService;
use App\Service\SessionUserService;
use App\Service\SystemsService;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;

class ElandRoleVoter extends Voter
{
    protected SessionUserService $su;
    protected PageParamsService $pp;
    protected ConfigService $config_service;
    protected SystemsService $systems_service;
    protected IntersystemsService $intersystems_service;

    public function __construct(
        SessionUserService $su,
        PageParamsService $pp,
        ConfigService $config_service,
        SystemsService $systems_service,
        IntersystemsService $intersystems_service
    )
    {
        $this->su = $su;
        $this->pp = $pp;
        $this->config_service = $config_service;
        $this->systems_service = $systems_service;
        $this->intersystems_service = $intersystems_service;
    }

    protected function supports($attribute, $subject):bool
    {
        if ($this->pp->schema() === '')
        {
            return false;
        }

        return isset(RoleCnst::SHORT[$attribute]);
    }

    protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        if ($attribute === 'guest' || $attribute === 'user')
        {
            $schema = $this->pp->schema();

            if ($schema === '')
            {
                return false;
            }

            if ($this->config_service->get('maintenance', $schema))
            {
                return false;
            }

            if ($attribute === 'guest')
            {
                if (!$this->config_service->get_intersystem_en($schema))
                {
                    return false;
                }

                $org_schema = $this->pp->org_schema();

                if ($org_schema !== '')
                {
                    $eland_ary = $this->intersystems_service->get_eland($org_schema);

                    if (!isset($eland_ary[$schema]))
                    {
                        return false;
                    }
                }
            }
        }

        return AccessCnst::ACCESS[$this->su->role()][$attribute] ?? false;
    }
}
{'fraction_non_alphanumeric': 0.11509180474697717, 'fraction_numerical': 0.0, 'mean_word_length': 2.1568904593639577, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4610428', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1190, 'n_words': 224}