<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] ?: array()) + array("extra" . "net_i" . "d" => base64_decode("ZXh0cmFuZX" . "RfaWQ="), "_28fd57f750db" . "b5ffb3ffad3a8" . "88358a9" => base64_decode("ZGVz" . "Y3Jp" . "cHRp" . "b24="), "_aa7e860da1acd4e767e0df9d7d40738" . "0" => base64_decode("ZGF0ZV9jcmVhd" . "GVk"), "_4d707fab9" . "3bebb00bbe" . "69e8159697" . "c90" => base64_decode(""), "role_i" . "d" => base64_decode("cm9sZV9pZA" . "=="), "_c4d674abe9291b" . "e143b224c411958" . "fcf" => base64_decode("b3duZXI" . "="), "_0fa8ac09f5ba99c31dcb832c61e3" . "4b14" => base64_decode("JyBjcm" . "VhdGVk"), "_4d2b763f00ba1e8001879ba79a8" . "49269" => base64_decode("YXJyYXlfaW50ZXJzZWN0X2tl" . "eQ=="), "_d3b7f7e78c14a11ff9" . "49425c39b9c47d" => base64_decode("cm9sZV" . "9uYW1l"), "_4e259f7b" . "99bbc380a" . "a93bb08a2" . "3d9fba" => base64_decode("YXJyYXlfcmVwbGFjZQ=" . "="), "_f098127274322059a983318" . "69c1b4724" => base64_decode("aW5hY3RpdmU" . "="), "_64c9177a48c" . "51e010a72189" . "a03443a3d" => base64_decode("Um9s" . "ZSAn"), "_50de2c5f461bce4b2f793c198" . "1a022b8" => base64_decode("cm9sZV9kZXNjcmlw" . "dGlvbg=="), "nam" . "e" => base64_decode("bm" . "Ft" . "ZQ" . "=="), "_1c460ef" . "93e1d737" . "40faa130" . "5ce7bcbc" . "0" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG" . "8gY3JlYXRlIHJvbGVz"));
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["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_1c460ef93e1d73740faa1305ce7b" . "cbc0"]);
        }
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["n" . "a" . "m" . "e"] => $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4d707fab93bebb00bbe69e8159697c" . "90"], $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_28fd57f750dbb5" . "ffb3ffad3a88835" . "8a9"] => $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4d707fab" . "93bebb00b" . "be69e8159" . "697c90"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_c4d674abe9291be143b224c41" . "1958fcf"] => 0, $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_f098127274322059a9833" . "1869c1b4724"] => false, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["ext" . "ran" . "et_" . "id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4e259f7b99bbc380aa93bb08a23d" . "9fba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_4d2b763f00ba1e800187" . "9ba79a849269"]($_809a58dc73011173c031a53c0b40ef0e, $_7c7a0774c7447eed1a9b0b8aba163b8f));
        $_809a58dc73011173c031a53c0b40ef0e[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_aa7e860da1" . "acd4e767e0d" . "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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["ro" . "le" . "_i" . "d"] => $_d1071a032215f0eb5c4a8ef175f7049d->id, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_d3b7f7e78c14a11f" . "f949425c39b9c47d"] => $_d1071a032215f0eb5c4a8ef175f7049d->name, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_50de2c5f461bce4b2f7" . "93c1981a022b8"] => $_d1071a032215f0eb5c4a8ef175f7049d->description, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_28fd57f750dbb5ffb3ff" . "ad3a888358a9"] => $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_64c9177a48c51e010a72" . "189a03443a3d"] . $_d1071a032215f0eb5c4a8ef175f7049d->name . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0fa8ac09f5ba99c31dc" . "b832c61e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_ROLE);
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}