<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("_0c5804dad44be89b52ac133270787" . "ec8" => base64_decode("JyB" . "1cG" . "Rhd" . "GVk"), "_64c9177a48c51e010a72189a03443a3" . "d" => base64_decode("Um9sZ" . "SAn"), "_28fd57f750dbb5ffb3ffad3a8883" . "58a9" => base64_decode("ZGVzY3JpcHRpb2" . "4="), "nam" . "e" => base64_decode("bmFtZQ=" . "="), "_94c782c818" . "0766e1ff187" . "0975a93053d" => base64_decode("Um9sZSBub3Q" . "gZm91bmQ="), "_28685591" . "a1d64debd" . "044e3074d" . "01b84d" => base64_decode("b3du" . "ZXJf" . "aWQ="), "_8226805203" . "27e9387ae2d" . "5c065ea52e1" => base64_decode("YXJyYXlfZm" . "xpcA=="), "ro" . "le" . "_i" . "d" => base64_decode("cm9sZV9pZA=" . "="), "_264b231c1d76" . "ced40a95b1615" . "6b68cd9" => base64_decode("WW91IGRvIG5vdCBoYXZlIHB" . "lcm1pc3Npb24gdG8gdXBkYX" . "RlIHRoaXMgcm9sZQ=="), "_f098127274322059a983" . "31869c1b4724" => base64_decode("aW5hY3RpdmU" . "="), "extran" . "et_id" => base64_decode("ZXh0cmFuZX" . "RfaWQ="), "_50de2c5f461bce4b2f" . "793c1981a022b8" => base64_decode("cm9sZV9" . "kZXNjcm" . "lwdGlvb" . "g=="), "_4d2b763f00ba1e" . "8001879ba79a849" . "269" => base64_decode("YXJyYXlfaW50ZXJz" . "ZWN0X2tleQ=="), "_d3b7f7e78c14a11ff9494" . "25c39b9c47d" => base64_decode("cm9sZV9uY" . "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 $_8652ba33e6ffeba02459fa9cbb320851, EventDispatcherInterface $dispatcher)
    {
        $this->acl = $acl;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->repository = $_8652ba33e6ffeba02459fa9cbb320851;
        $this->dispatcher = $dispatcher;
    }
    
    
    
    
    
    
    
    
    
    
    
    public function UpdateRole(SecurityContext $context, int $id, array $_809a58dc73011173c031a53c0b40ef0e)
    {
        
        
        
        
        
        
        $_d1071a032215f0eb5c4a8ef175f7049d = $this->repository->find($id);
        if (!$_d1071a032215f0eb5c4a8ef175f7049d) {
            throw new NotFoundException($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_94c782c8180766e1ff1870975" . "a93053d"]);
        }
        if (!$this->acl->CanUpdateRole($context, $_d1071a032215f0eb5c4a8ef175f7049d)) {
            throw new PermissionException($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_264b231c1d7" . "6ced40a95b16" . "156b68cd9"]);
        }
        
        
        $_f5808a5c364490e091e9435951fbb267 = [$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["na" . "me"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_28fd57f750dbb5ffb3ffad3a8" . "88358a9"], $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_f0981272743" . "22059a983318" . "69c1b4724"], $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_28685591a1d64debd044e30" . "74d01b84d"], $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["extranet_" . "id"]];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_4d2b763f00ba1e800187" . "9ba79a849269"]($_809a58dc73011173c031a53c0b40ef0e, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_822680520327e938" . "7ae2d5c065ea52e1"]($_f5808a5c364490e091e9435951fbb267));
        $_d1071a032215f0eb5c4a8ef175f7049d->fill($_809a58dc73011173c031a53c0b40ef0e);
        $this->validator->Validate($_d1071a032215f0eb5c4a8ef175f7049d);
        $this->repository->store($_d1071a032215f0eb5c4a8ef175f7049d);
        $event = new GenericEvent($_d1071a032215f0eb5c4a8ef175f7049d, [$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["role_i" . "d"] => $_d1071a032215f0eb5c4a8ef175f7049d->id, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_d3b7f7e78c14a11ff949425c39b" . "9c47d"] => $_d1071a032215f0eb5c4a8ef175f7049d->name, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_50de2c5f461bce4b2f793c1981a022" . "b8"] => $_d1071a032215f0eb5c4a8ef175f7049d->description, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_28fd57f7" . "50dbb5ffb" . "3ffad3a88" . "8358a9"] => $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_64c9177a48c51e010a72" . "189a03443a3d"] . $_d1071a032215f0eb5c4a8ef175f7049d->name . $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_0c5804dad44be89b52ac1332707" . "87ec8"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::UPDATE_ROLE);
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}