<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] = (@$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] ?: array()) + array("_28fd57f750dbb5ffb3ffad3a8883" . "58a9" => base64_decode("ZGVzY3JpcHRp" . "b24="), "extr" . "anet" . "_id" => base64_decode("ZXh0cmFuZXRf" . "aWQ="), "_7e9f8a597558166" . "2858d88b41f28c37" . "5" => base64_decode("R3JvdXAgJ" . "w=="), "_82268052" . "0327e9387" . "ae2d5c065" . "ea52e1" => base64_decode("YXJyYXlfZmxp" . "cA=="), "n" . "a" . "m" . "e" => base64_decode("bmFtZQ" . "=="), "_28685591a" . "1d64debd04" . "4e3074d01b" . "84d" => base64_decode("b3d" . "uZX" . "Jfa" . "WQ="), "_074be1464f775a64053bd002e3b696e" . "4" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8gdXBkYXRlIGdyb3VwI" . "A=="), "_f098127274322059a983" . "31869c1b4724" => base64_decode("aW5hY3RpdmU" . "="), "_794d33ac114ec83" . "bc563988f7b0719c" . "9" => base64_decode("cGVvcGxlLmVycm9yLmdyb3VwX25vdF9mb3V" . "uZA=="), "par" . "ent" . "_id" => base64_decode("cGFy" . "ZW50" . "X2lk"), "_0c5804dad44be89b52ac" . "133270787ec8" => base64_decode("JyB1cGR" . "hdGVk"), "_2176251d6" . "bf95f12609" . "992c4c4b89" . "cd2" => base64_decode("Z3JvdXBfZGVzY3" . "JpcHRpb24="), "_4d2b763f00ba" . "1e8001879ba79" . "a849269" => base64_decode("YXJyYXlfaW50ZXJzZWN0X2tleQ" . "=="), "grou" . "p_id" => base64_decode("Z3JvdXB" . "faWQ="));
use Analogue\ORM\Exceptions\MappingException;
use Claromentis\Core\Event\EventDispatcher;
use Claromentis\Core\Event\GenericEvent;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\Group;
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\GroupRepository;
use Claromentis\People\Validator\GroupValidator;
class UpdateGroup
{
    
    
    
    
    protected $acl;
    
    
    
    
    protected $validator;
    
    
    
    
    protected $repository;
    
    
    
    
    protected $dispatcher;
    
    
    
    
    protected $lmsg;
    
    
    
    
    
    
    
    
    public function __construct(PeopleAcl $acl, GroupValidator $_24c8d051c033d19c2c97cdc3d7098b1b, GroupRepository $_8652ba33e6ffeba02459fa9cbb320851, EventDispatcher $dispatcher, Lmsg $lmsg)
    {
        $this->acl = $acl;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->repository = $_8652ba33e6ffeba02459fa9cbb320851;
        $this->dispatcher = $dispatcher;
        $this->lmsg = $lmsg;
    }
    
    
    
    
    
    
    
    
    
    
    
    public function UpdateGroup(SecurityContext $context, int $id, array $_809a58dc73011173c031a53c0b40ef0e)
    {
        
        
        
        
        
        
        $_e9208e4fb555ac989f7519e19c1da810 = $this->repository->find($id);
        if (!$_e9208e4fb555ac989f7519e19c1da810) {
            throw new NotFoundException(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_794d33ac11" . "4ec83bc5639" . "88f7b0719c9"]));
        }
        if (!$this->acl->CanUpdateGroup($context, $_e9208e4fb555ac989f7519e19c1da810)) {
            throw new PermissionException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_074be1464f775a64053bd002e3b696e" . "4"] . $_e9208e4fb555ac989f7519e19c1da810->id);
        }
        
        
        $_f5808a5c364490e091e9435951fbb267 = [$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["n" . "a" . "m" . "e"], $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_28fd57f750dbb5ffb3ffad3a8" . "88358a9"], $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["pa" . "re" . "nt" . "_i" . "d"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_28685591a1d" . "64debd044e30" . "74d01b84d"], $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_f098127274322059a9" . "8331869c1b4724"], $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["extrane" . "t_id"]];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d2b763f00ba1e800" . "1879ba79a849269"]($_809a58dc73011173c031a53c0b40ef0e, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_82268052032" . "7e9387ae2d5c" . "065ea52e1"]($_f5808a5c364490e091e9435951fbb267));
        $_e9208e4fb555ac989f7519e19c1da810->fill($_809a58dc73011173c031a53c0b40ef0e);
        $this->validator->Validate($_e9208e4fb555ac989f7519e19c1da810);
        $this->repository->store($_e9208e4fb555ac989f7519e19c1da810);
        $event = new GenericEvent($_e9208e4fb555ac989f7519e19c1da810, [$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["group" . "_id"] => $_e9208e4fb555ac989f7519e19c1da810->id, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_2176251d6bf95f12609" . "992c4c4b89cd2"] => $_e9208e4fb555ac989f7519e19c1da810->description, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_28fd57f750dbb5ffb3" . "ffad3a888358a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_7e9f8a5975581662858d88b41" . "f28c375"] . $_e9208e4fb555ac989f7519e19c1da810->name . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_0c5804dad" . "44be89b52a" . "c133270787" . "ec8"]]);
        $this->dispatcher->dispatch(PeopleEventType::UPDATE_GROUP, $event);
        return $_e9208e4fb555ac989f7519e19c1da810;
    }
}