<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] = (@$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] ?: array()) + array("_6c8c538" . "7f046854" . "f266c918" . "d1562fe2" . "3" => base64_decode("cGVvcGxlLmVycm9yLmV4dHJ" . "hbmV0X3ByaW1hcnlfZm9yYm" . "lkZGVu"), "_f77bfca3490ee96b0c88c8733ef" . "e7c5c" => base64_decode("RXh0cmFuZXQgd2l0a" . "CBJRCA="), "_fa96cdf58bff3b0695fb2" . "bc0803d7b12" => base64_decode("IGRvZX" . "Mgbm90" . "IGV4aX" . "N0"));
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\Extranet;
use Claromentis\People\Exception\PermissionException;
use Claromentis\People\Exception\ValidationException;
use Claromentis\People\PeopleAcl;
use Claromentis\People\Repository\ExtranetRepository;
class SetPrimaryExtranet
{
    
    
    
    
    protected $acl;
    
    
    
    
    protected $lmsg;
    
    
    
    
    protected $repository;
    public function __construct(PeopleAcl $acl, Lmsg $lmsg, ExtranetRepository $repository)
    {
        $this->acl = $acl;
        $this->lmsg = $lmsg;
        $this->repository = $repository;
    }
    
    
    
    
    
    
    
    
    public function SetPrimaryExtranet(SecurityContext $context, int $id)
    {
        if (!$this->acl->IsPeopleAdmin($context)) {
            throw new PermissionException(($this->lmsg)($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_6c8c5387f046854f266c918d1562f" . "e23"]));
        }
        
        
        $_9a2ef4ae6a5745ffe5fac33c88a222fa = $this->repository->find($id);
        if (!$_9a2ef4ae6a5745ffe5fac33c88a222fa) {
            throw new ValidationException($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_f77bfca3490ee96b0c88c8733efe7" . "c5c"] . $id . $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_fa96cdf" . "58bff3b0" . "695fb2bc" . "0803d7b1" . "2"]);
        }
        $this->repository->setPrimaryExtranet($_9a2ef4ae6a5745ffe5fac33c88a222fa);
    }
}