<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] ?: array()) + array("na" . "me" => base64_decode("bm" . "Ft" . "ZQ" . "=="), "_822680520327e93" . "87ae2d5c065ea52e" . "1" => base64_decode("YXJyYXlfZmxpcA=" . "="), "ext" . "ran" . "et_" . "id" => base64_decode("ZXh0cmFuZXR" . "faWQ="), "_64c9177a48c51e010a72189a" . "03443a3d" => base64_decode("Um9sZS" . "An"), "_50de2c5f461bce4b2f7" . "93c1981a022b8" => base64_decode("cm9sZV9kZXNjcmlwd" . "Glvbg=="), "_f098127274322059a98331869c1b4" . "724" => base64_decode("aW5hY3R" . "pdmU="), "_0c5804dad" . "44be89b52a" . "c133270787" . "ec8" => base64_decode("JyB" . "1cG" . "Rhd" . "GVk"), "_d3b7f7e" . "78c14a11" . "ff949425" . "c39b9c47" . "d" => base64_decode("cm9sZV9uYW" . "1l"), "_28685591" . "a1d64debd" . "044e3074d" . "01b84d" => base64_decode("b3duZXJ" . "faWQ="), "_264b231c1d76ced40a95b16156b68c" . "d9" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8gdXBkY" . "XRlIHRoaXMgcm9sZQ=="), "_4d2b763f00ba1e8001879b" . "a79a849269" => base64_decode("YXJyYXlfa" . "W50ZXJzZW" . "N0X2tleQ=" . "="), "rol" . "e_i" . "d" => base64_decode("cm9s" . "ZV9p" . "ZA=="), "_94c782c8180766e1ff1870975" . "a93053d" => base64_decode("Um9sZSBub3QgZm91b" . "mQ="), "_28fd57f750dbb5" . "ffb3ffad3a88835" . "8a9" => base64_decode("ZGVzY3JpcHR" . "pb24="));
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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_94c782c8180766e1ff1870975a" . "93053d"]);
        }
        if (!$this->acl->CanUpdateRole($context, $_d1071a032215f0eb5c4a8ef175f7049d)) {
            throw new PermissionException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_264b231c1d76ced" . "40a95b16156b68cd" . "9"]);
        }
        
        
        $_f5808a5c364490e091e9435951fbb267 = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["nam" . "e"], $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_28fd57f750dbb5f" . "fb3ffad3a888358a" . "9"], $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_f098127274322059a983318" . "69c1b4724"], $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_28685591a1d64debd044e" . "3074d01b84d"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["extra" . "net_i" . "d"]];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d2b763f00ba1e8001879" . "ba79a849269"]($_809a58dc73011173c031a53c0b40ef0e, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_822680520327e9387ae2d5c065ea" . "52e1"]($_f5808a5c364490e091e9435951fbb267));
        $_d1071a032215f0eb5c4a8ef175f7049d->fill($_809a58dc73011173c031a53c0b40ef0e);
        $this->validator->Validate($_d1071a032215f0eb5c4a8ef175f7049d);
        $this->repository->store($_d1071a032215f0eb5c4a8ef175f7049d);
        $event = new GenericEvent($_d1071a032215f0eb5c4a8ef175f7049d, [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["role_i" . "d"] => $_d1071a032215f0eb5c4a8ef175f7049d->id, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_d3b7f7e78c14a11ff949425c39b9" . "c47d"] => $_d1071a032215f0eb5c4a8ef175f7049d->name, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_50de2c5f461bce4b2f7" . "93c1981a022b8"] => $_d1071a032215f0eb5c4a8ef175f7049d->description, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_28fd57f" . "750dbb5f" . "fb3ffad3" . "a888358a" . "9"] => $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_64c9177a48c51e010a72189a" . "03443a3d"] . $_d1071a032215f0eb5c4a8ef175f7049d->name . $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_0c5804dad44be89b52ac13327078" . "7ec8"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::UPDATE_ROLE);
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}