<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] ?: array()) + array("_28685591a1d64debd044e3074" . "d01b84d" => base64_decode("b3duZXJfa" . "WQ="), "_822680520327e9387ae2d5c06" . "5ea52e1" => base64_decode("YXJyYXlfZmx" . "pcA=="), "_94c782c8180766e1ff" . "1870975a93053d" => base64_decode("Um9sZSBub3QgZm91bm" . "Q="), "_0c5804dad44be89b52ac1332" . "70787ec8" => base64_decode("JyB1" . "cGRh" . "dGVk"), "extrane" . "t_id" => base64_decode("ZXh0cmFuZXRf" . "aWQ="), "_50de2c5f" . "461bce4b2" . "f793c1981" . "a022b8" => base64_decode("cm9sZV9kZXNjcmlw" . "dGlvbg=="), "_264b231c1d7" . "6ced40a95b16" . "156b68cd9" => base64_decode("WW91IGRvIG5vdCBo" . "YXZlIHBlcm1pc3Np" . "b24gdG8gdXBkYXRl" . "IHRoaXMgcm9sZQ=="), "_28fd57f750dbb5ffb3ffad3a8883" . "58a9" => base64_decode("ZGVzY3JpcH" . "Rpb24="), "_64c9177" . "a48c51e0" . "10a72189" . "a03443a3" . "d" => base64_decode("Um9sZSA" . "n"), "_4d2b763f00ba1e800187" . "9ba79a849269" => base64_decode("YXJyYXlfaW50ZXJzZWN0X2tle" . "Q=="), "rol" . "e_i" . "d" => base64_decode("cm9sZV9pZA" . "=="), "na" . "me" => base64_decode("bmFtZQ=" . "="), "_f098127274322059a98" . "331869c1b4724" => base64_decode("aW5hY3" . "RpdmU="), "_d3b7f7e78c14a11ff94942" . "5c39b9c47d" => base64_decode("cm9" . "sZV" . "9uY" . "W1l"));
use Analogue\ORM\Exceptions\MappingException;
use Claromentis\Core\Event\EventDispatcher;
use Claromentis\Core\Event\GenericEvent;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\Role;
use Claromentis\People\Event\PeopleEventType;
use Claromentis\People\Exception\NotFoundException;
use Claromentis\People\Exception\PermissionException;
use Claromentis\People\Exception\ValidationException;
use Claromentis\People\PeopleAcl;
use Claromentis\People\Repository\RoleRepository;
use Claromentis\People\Validator\RoleValidator;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class UpdateRole
{
    
    
    
    
    protected $acl;
    
    
    
    
    protected $validator;
    
    
    
    
    protected $repository;
    
    
    
    
    protected $dispatcher;
    
    
    
    
    
    
    
    public function __construct(PeopleAcl $acl, RoleValidator $_24c8d051c033d19c2c97cdc3d7098b1b, RoleRepository $repository, EventDispatcherInterface $dispatcher)
    {
        $this->acl = $acl;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->repository = $repository;
        $this->dispatcher = $dispatcher;
    }
    
    
    
    
    
    
    
    
    
    
    
    public function UpdateRole(SecurityContext $context, int $id, array $_809a58dc73011173c031a53c0b40ef0e)
    {
        
        
        
        
        
        
        $_d1071a032215f0eb5c4a8ef175f7049d = $this->repository->find($id);
        if (!$_d1071a032215f0eb5c4a8ef175f7049d) {
            throw new NotFoundException($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_94c782c8" . "180766e1f" . "f1870975a" . "93053d"]);
        }
        if (!$this->acl->CanUpdateRole($context, $_d1071a032215f0eb5c4a8ef175f7049d)) {
            throw new PermissionException($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_264b231c1d76ced40a95b1615" . "6b68cd9"]);
        }
        
        
        $_f5808a5c364490e091e9435951fbb267 = [$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["n" . "a" . "m" . "e"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_28fd57f750dbb5ffb3" . "ffad3a888358a9"], $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_f09812727432" . "2059a98331869" . "c1b4724"], $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_28685591a1d64debd044e" . "3074d01b84d"], $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["ext" . "ran" . "et_" . "id"]];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4d2b763f" . "00ba1e800" . "1879ba79a" . "849269"]($_809a58dc73011173c031a53c0b40ef0e, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_822680520327e9387a" . "e2d5c065ea52e1"]($_f5808a5c364490e091e9435951fbb267));
        $_d1071a032215f0eb5c4a8ef175f7049d->fill($_809a58dc73011173c031a53c0b40ef0e);
        $this->validator->Validate($_d1071a032215f0eb5c4a8ef175f7049d);
        $this->repository->store($_d1071a032215f0eb5c4a8ef175f7049d);
        $event = new GenericEvent($_d1071a032215f0eb5c4a8ef175f7049d, [$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["role" . "_id"] => $_d1071a032215f0eb5c4a8ef175f7049d->id, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_d3b7f7e78c14a11ff949425c39b9" . "c47d"] => $_d1071a032215f0eb5c4a8ef175f7049d->name, $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_50de2c5f461bce4b2f793c1981a0" . "22b8"] => $_d1071a032215f0eb5c4a8ef175f7049d->description, $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_28fd57f750dbb5ffb3ffad" . "3a888358a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_64c9177a48c51e01" . "0a72189a03443a3d"] . $_d1071a032215f0eb5c4a8ef175f7049d->name . $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_0c5804dad44be89b52ac133270787e" . "c8"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::UPDATE_ROLE);
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}