<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] ?: array()) + array("_4d2b763f00ba" . "1e8001879ba79" . "a849269" => base64_decode("YXJyYXlfaW50ZXJzZWN0X2tleQ" . "=="), "_1c460ef93e1d73740fa" . "a1305ce7bcbc0" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc" . "3Npb24gdG8gY3JlYXRlIHJvbGVz"), "_50de2c5f461bce4b2f793c1981a02" . "2b8" => base64_decode("cm9sZV9kZ" . "XNjcmlwdG" . "lvbg=="), "_64c9177a" . "48c51e010" . "a72189a03" . "443a3d" => base64_decode("Um9sZSA" . "n"), "_4d707fab93bebb00bb" . "e69e8159697c90" => base64_decode(""), "na" . "me" => base64_decode("bmFtZ" . "Q=="), "_c4d674abe9291be143b224c411" . "958fcf" => base64_decode("b3duZXI" . "="), "_f098127274322059a98331" . "869c1b4724" => base64_decode("aW5hY3" . "RpdmU="), "extranet" . "_id" => base64_decode("ZXh0cmFuZX" . "RfaWQ="), "_d3b7f7e78" . "c14a11ff94" . "9425c39b9c" . "47d" => base64_decode("cm9sZV" . "9uYW1l"), "_aa7e860da1acd4e767e0df" . "9d7d407380" => base64_decode("ZGF0ZV9" . "jcmVhdG" . "Vk"), "_28fd57f75" . "0dbb5ffb3f" . "fad3a88835" . "8a9" => base64_decode("ZGVzY3JpcH" . "Rpb24="), "_4e259f7b99bbc380aa93bb08a23d9f" . "ba" => base64_decode("YXJyYXl" . "fcmVwbG" . "FjZQ=="), "role" . "_id" => base64_decode("cm9sZV9" . "pZA=="), "_0fa8ac09f5ba99c31dcb832c61e34b1" . "4" => base64_decode("JyBjcmVh" . "dGVk"));
use Analogue\ORM\Exceptions\MappingException;
use Claromentis\Core\Acl\PermOClass;
use Claromentis\Core\Event\GenericEvent;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\Role;
use Claromentis\People\Event\PeopleEventType;
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 Date;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;




class CreateRole
{
    
    
    
    
    protected $acl;
    
    
    
    
    protected $validator;
    
    
    
    
    protected $repository;
    
    
    
    
    protected $dispatcher;
    
    
    
    
    
    
    
    public function __construct(PeopleAcl $acl, RoleValidator $_24c8d051c033d19c2c97cdc3d7098b1b, RoleRepository $repository, EventDispatcherInterface $dispatcher)
    {
        $this->acl = $acl;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->repository = $repository;
        $this->dispatcher = $dispatcher;
    }
    
    
    
    
    
    
    
    
    
    public function CreateRole(SecurityContext $context, array $_809a58dc73011173c031a53c0b40ef0e) : Role
    {
        if (!$this->acl->CanCreateRole($context)) {
            throw new PermissionException($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_1c460ef93e1d73740faa1305ce7bc" . "bc0"]);
        }
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["n" . "a" . "m" . "e"] => $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_4d707fab93bebb00bbe69e815" . "9697c90"], $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_28fd57f750dbb5ffb3ffad3a" . "888358a9"] => $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4d707fab93bebb00bbe69e8159" . "697c90"], $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_c4d674abe9291be143b224c41" . "1958fcf"] => 0, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_f098127274322059a98331" . "869c1b4724"] => false, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["extranet" . "_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_4e259f7b99bbc380aa93bb08a23d9" . "fba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_4d2b763f00ba1e8001879" . "ba79a849269"]($_809a58dc73011173c031a53c0b40ef0e, $_7c7a0774c7447eed1a9b0b8aba163b8f));
        $_809a58dc73011173c031a53c0b40ef0e[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_aa7e860da1a" . "cd4e767e0df9" . "d7d407380"]] = new Date();
        
        
        $_d1071a032215f0eb5c4a8ef175f7049d = new Role();
        $_d1071a032215f0eb5c4a8ef175f7049d->fill($_809a58dc73011173c031a53c0b40ef0e);
        $this->validator->Validate($_d1071a032215f0eb5c4a8ef175f7049d);
        $this->repository->store($_d1071a032215f0eb5c4a8ef175f7049d);
        $this->acl->AddObject($context, PermOClass::ROLE, $_d1071a032215f0eb5c4a8ef175f7049d->id);
        
        
        $event = new GenericEvent($_d1071a032215f0eb5c4a8ef175f7049d, [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["role" . "_id"] => $_d1071a032215f0eb5c4a8ef175f7049d->id, $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_d3b7f7e78c14a11ff949425c39" . "b9c47d"] => $_d1071a032215f0eb5c4a8ef175f7049d->name, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_50de2c5f461bce4b2f" . "793c1981a022b8"] => $_d1071a032215f0eb5c4a8ef175f7049d->description, $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_28fd57f75" . "0dbb5ffb3f" . "fad3a88835" . "8a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_64c9177a48c51" . "e010a72189a034" . "43a3d"] . $_d1071a032215f0eb5c4a8ef175f7049d->name . $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_0fa8ac09f5ba99c31dc" . "b832c61e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_ROLE);
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}