<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] ?: array()) + array("_c2a7246442dfecfa995" . "1bd031867c498" => base64_decode("KSBoYXMgaGFkIHRoZWlyIGxpc3Qg" . "b2Ygc3Vib3JkaW5hdGVzIHVwZGF0" . "ZWQu"), "_28fd57f750d" . "bb5ffb3ffad3" . "a888358a9" => base64_decode("ZGVzY3Jp" . "cHRpb24="), "_f149cf29770e82095e99" . "2315e2ab26e2" => base64_decode("KA" . "=="), "_ed6dc57c5eb21728a" . "3c52c0d8c964c5d" => base64_decode("VXNlciBub3Qg" . "Zm91bmQgd2l0" . "aCBpZCA="), "_76d1461" . "2538e52c" . "5e6329ce" . "4fa353f1" . "a" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8gZWRpdCB0aGlz" . "IHVzZXI="));
use Claromentis\Core\Event\EventDispatcher;
use Claromentis\Core\Event\GenericEvent;
use Claromentis\Core\Security\Exception\AccessDeniedException;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\User;
use Claromentis\People\Event\PeopleEventType;
use Claromentis\People\Exception\NotFoundException;
use Claromentis\People\Exception\ValidationException;
use Claromentis\People\PeopleAcl;
use Claromentis\People\Repository\UserRepository;
use Claromentis\People\UsersHierarchyService;
use Claromentis\People\Validator\SubordinatesValidator;
use Claromentis\People\Validator\Util;
class SetSubordinates
{
    
    
    
    
    protected $acl;
    
    
    
    
    protected $hierarchy_service;
    
    
    
    
    protected $validator;
    
    
    
    
    protected $user_repository;
    
    
    
    
    protected $event_dispatcher;
    public function __construct(PeopleAcl $acl, UsersHierarchyService $_59dfd60487c7d5e6828b1f906741c1a4, SubordinatesValidator $_24c8d051c033d19c2c97cdc3d7098b1b, EventDispatcher $event_dispatcher, UserRepository $_eeeeb0d673b7b0fd0bdca58b5541c3e0)
    {
        $this->acl = $acl;
        $this->hierarchy_service = $_59dfd60487c7d5e6828b1f906741c1a4;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->user_repository = $_eeeeb0d673b7b0fd0bdca58b5541c3e0;
        $this->event_dispatcher = $event_dispatcher;
    }
    
    
    
    
    
    
    
    
    
    public function SetSubordinates(SecurityContext $context, int $user_id, array $_02ea59b60fd989f4aa27981354472f33)
    {
        $this->validator->ValidateSubordinates($_02ea59b60fd989f4aa27981354472f33);
        
        
        $_24e0e36600d6af77406a44bb618a6253 = $this->user_repository->find($user_id);
        if (!$_24e0e36600d6af77406a44bb618a6253) {
            throw new NotFoundException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_ed6dc57" . "c5eb2172" . "8a3c52c0" . "d8c964c5" . "d"] . $user_id);
        }
        if (!$this->acl->CanUpdateUser($context, $_24e0e36600d6af77406a44bb618a6253)) {
            throw new AccessDeniedException($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_76d1461" . "2538e52c" . "5e6329ce" . "4fa353f1" . "a"]);
        }
        Util::ValidateIds($_02ea59b60fd989f4aa27981354472f33);
        $this->hierarchy_service->SetSubordinates($user_id, $_02ea59b60fd989f4aa27981354472f33);
        $_28fd57f750dbb5ffb3ffad3a888358a9 = $_24e0e36600d6af77406a44bb618a6253->fullname . $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_f149cf2" . "9770e820" . "95e99231" . "5e2ab26e" . "2"] . $_24e0e36600d6af77406a44bb618a6253->id . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_c2a7246442dfe" . "cfa9951bd03186" . "7c498"];
        
        
        
        
        $event = new GenericEvent($_24e0e36600d6af77406a44bb618a6253, [$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_28fd57f750dbb5ffb3ffad3a888" . "358a9"] => $_28fd57f750dbb5ffb3ffad3a888358a9]);
        $this->event_dispatcher->dispatch(PeopleEventType::SET_USER_SUBORDINATES, $event);
    }
}