<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] = (@$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] ?: array()) + array("_e4543e131c67c631b14751cc" . "849d1310" => base64_decode("dXNlcn" . "M="), "_ca7ee538a80637573dd3e5c1997" . "a0512" => base64_decode("Tm8gcGVybWlzc2lvbiB0byBhc3Np" . "Z24gdG8gZXh0cmFuZXQgYXJlYSBJ" . "RCA="));
use Analogue\ORM\EntityCollection;
use Analogue\ORM\Exceptions\MappingException;
use Claromentis\Core\Event\EventDispatcher;
use Claromentis\Core\Event\GenericEvent;
use Claromentis\Core\Security\Exception\AccessDeniedException;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Event\PeopleEventType;
use Claromentis\People\Exception\NotFoundException;
use Claromentis\People\PeopleAcl;
use Claromentis\People\Repository\ExtranetRepository;
use Claromentis\People\Exception\ValidationException;
use Claromentis\People\Validator\ExtranetValidator;
use Claromentis\People\Validator\Util;
class SetExtranetUsers
{
    
    
    
    
    protected $acl;
    
    
    
    
    protected $dispatcher;
    
    
    
    
    private $repo;
    
    
    
    
    private $validator;
    public function __construct(ExtranetRepository $repo, ExtranetValidator $_24c8d051c033d19c2c97cdc3d7098b1b, PeopleAcl $acl, EventDispatcher $dispatcher)
    {
        $this->repo = $repo;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->acl = $acl;
        $this->dispatcher = $dispatcher;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function UpdateExtranetUsers(SecurityContext $context, int $extranet_id, array $_17247f55ce15f647f57c3ef8bb3a474a) : EntityCollection
    {
        if (!$this->acl->CanAssignExtranetUsers($context, $extranet_id)) {
            throw new AccessDeniedException($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_ca7ee538a80637573dd3e5c1997" . "a0512"] . $extranet_id);
        }
        Util::ValidateIds($_17247f55ce15f647f57c3ef8bb3a474a);
        $this->validator->ValidateUserList($extranet_id, $_17247f55ce15f647f57c3ef8bb3a474a);
        $_e4543e131c67c631b14751cc849d1310 = $this->repo->updateUserExtranet($extranet_id, $_17247f55ce15f647f57c3ef8bb3a474a);
        $_9a2ef4ae6a5745ffe5fac33c88a222fa = $this->repo->find($extranet_id);
        $event = new GenericEvent($_9a2ef4ae6a5745ffe5fac33c88a222fa, [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_e4543e131c67c631b14751cc8" . "49d1310"] => $_e4543e131c67c631b14751cc849d1310]);
        $this->dispatcher->dispatch(PeopleEventType::SET_EXTRANET_USERS, $event);
        return $_e4543e131c67c631b14751cc849d1310;
    }
}