<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] ?: array()) + array("nam" . "e" => base64_decode("bmF" . "tZQ" . "=="), "_c4d674abe9291be143b" . "224c411958fcf" => base64_decode("b3duZ" . "XI="), "extra" . "net_i" . "d" => base64_decode("ZXh0cmFuZXR" . "faWQ="), "_0fa8ac09f" . "5ba99c31dc" . "b832c61e34" . "b14" => base64_decode("JyBjcmVhdG" . "Vk"), "_28fd57f750dbb5ff" . "b3ffad3a888358a9" => base64_decode("ZGVz" . "Y3Jp" . "cHRp" . "b24="), "_aa7e860da1acd4e767e0df9d7d4073" . "80" => base64_decode("ZGF0ZV9" . "jcmVhdG" . "Vk"), "_f098127274322059a98331869c" . "1b4724" => base64_decode("aW5hY3Rpd" . "mU="), "_50de2c5f461bce4b2f793c1981a02" . "2b8" => base64_decode("cm9sZV9kZXN" . "jcmlwdGlvbg" . "=="), "_4e259f7b" . "99bbc380a" . "a93bb08a2" . "3d9fba" => base64_decode("YXJyYXlfcmVw" . "bGFjZQ=="), "_d3b7f7e78c14a11" . "ff949425c39b9c47" . "d" => base64_decode("cm9sZV9uY" . "W1l"), "_1c460ef93e" . "1d73740faa1" . "305ce7bcbc0" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8" . "gY3JlYXRlIHJvbGVz"), "_64c9177a48c51e010a72" . "189a03443a3d" => base64_decode("Um" . "9s" . "ZS" . "An"), "ro" . "le" . "_i" . "d" => base64_decode("cm9sZV9pZ" . "A=="), "_4d707fab93bebb00bbe69e815" . "9697c90" => base64_decode(""), "_4d2b763f00ba1e8001879b" . "a79a849269" => base64_decode("YXJyYXlfaW50ZXJzZW" . "N0X2tleQ=="));
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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_1c460ef93e1d737" . "40faa1305ce7bcbc" . "0"]);
        }
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["na" . "me"] => $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_4d707fab93bebb00bb" . "e69e8159697c90"], $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_28fd57f750dbb5ffb3ffad3a8883" . "58a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_4d707fab93bebb00bbe" . "69e8159697c90"], $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_c4d674abe9291be14" . "3b224c411958fcf"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_f098127274322059a9" . "8331869c1b4724"] => false, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["extrane" . "t_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_4e259f7b99bbc380aa93bb08a23d9f" . "ba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d2b763f00ba1" . "e8001879ba79a8" . "49269"]($_809a58dc73011173c031a53c0b40ef0e, $_7c7a0774c7447eed1a9b0b8aba163b8f));
        $_809a58dc73011173c031a53c0b40ef0e[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_aa7e860da1acd4e767e0d" . "f9d7d407380"]] = 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["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["rol" . "e_i" . "d"] => $_d1071a032215f0eb5c4a8ef175f7049d->id, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_d3b7f7e78c14a" . "11ff949425c39b" . "9c47d"] => $_d1071a032215f0eb5c4a8ef175f7049d->name, $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_50de2c5f461b" . "ce4b2f793c198" . "1a022b8"] => $_d1071a032215f0eb5c4a8ef175f7049d->description, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_28fd57f750dbb5ffb3ffad3a88" . "8358a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_64c9177a48c51e010a" . "72189a03443a3d"] . $_d1071a032215f0eb5c4a8ef175f7049d->name . $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_0fa8ac09f5ba99c31d" . "cb832c61e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_ROLE);
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}