<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] ?: array()) + array("_94c782c8180766e1ff1870975a9305" . "3d" => base64_decode("Um9sZSBub3Q" . "gZm91bmQ="), "_f4532747e1604b7bf86" . "d299f9b9b0583" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb" . "24gdG8gdmlldyB0aGlzIHJvbGU="));
use Claromentis\Core\ORM\Exceptions\EntityNotFoundException;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\Role;
use Claromentis\People\Exception\NotFoundException;
use Claromentis\People\Exception\PermissionException;
use Claromentis\People\Filter\RoleFilter;
use Claromentis\People\PeopleAcl;
use Claromentis\People\Repository\RoleRepository;




class GetRole
{
    
    
    
    
    protected $acl;
    
    
    
    
    protected $repository;
    
    
    
    
    
    public function __construct(PeopleAcl $acl, RoleRepository $_8652ba33e6ffeba02459fa9cbb320851)
    {
        $this->acl = $acl;
        $this->repository = $_8652ba33e6ffeba02459fa9cbb320851;
    }
    
    
    
    
    
    
    
    
    
    public function GetRole(SecurityContext $context, int $role_id, ?RoleFilter $_03e9164d0a343b742df4793268b80767 = null) : Role
    {
        $_03e9164d0a343b742df4793268b80767 = $_03e9164d0a343b742df4793268b80767 ?? new RoleFilter($context);
        
        
        
        
        $_d1071a032215f0eb5c4a8ef175f7049d = $this->repository->findOneWithFilter($role_id, $_03e9164d0a343b742df4793268b80767);
        if (!$_d1071a032215f0eb5c4a8ef175f7049d) {
            throw new NotFoundException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_94c782c8180766e1ff1870975a" . "93053d"]);
        }
        if (!$this->acl->CanViewRole($context, $_d1071a032215f0eb5c4a8ef175f7049d)) {
            throw new PermissionException($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_f453274" . "7e1604b7" . "bf86d299" . "f9b9b058" . "3"]);
        }
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}