<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] ?: array()) + array("_28fd57f750dbb5ffb3ff" . "ad3a888358a9" => base64_decode("ZGVzY3JpcHRpb24" . "="), "extrane" . "t_id" => base64_decode("ZXh0" . "cmFu" . "ZXRf" . "aWQ="), "_4d707fab93bebb00bbe6" . "9e8159697c90" => base64_decode(""), "_4e259f7b99bbc380aa93bb08a23" . "d9fba" => base64_decode("YXJyYXlfcmVwbGFj" . "ZQ=="), "_64c9177a48c51e010a72189a03" . "443a3d" => base64_decode("Um9" . "sZS" . "An"), "_f0981272743220" . "59a98331869c1b4" . "724" => base64_decode("aW5hY3Rpdm" . "U="), "role_i" . "d" => base64_decode("cm9sZV9pZ" . "A=="), "na" . "me" => base64_decode("bmFt" . "ZQ=="), "_c4d674abe9" . "291be143b22" . "4c411958fcf" => base64_decode("b3du" . "ZXI="), "_1c460ef93e1d73740faa13" . "05ce7bcbc0" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24g" . "dG8gY3JlYXRlIHJvbGVz"), "_50de2c5f461bce4b2f793c1981" . "a022b8" => base64_decode("cm9sZV9kZXNjcmlwdGlv" . "bg=="), "_4d2b763f00ba1e8001879ba79a8492" . "69" => base64_decode("YXJyYXlfaW50ZXJzZWN0X2tleQ=" . "="), "_0fa8ac09f5ba99c31" . "dcb832c61e34b14" => base64_decode("JyBjcm" . "VhdGVk"), "_d3b7f7e78c14" . "a11ff949425c3" . "9b9c47d" => base64_decode("cm9sZV9uYW" . "1l"), "_aa7e860da1ac" . "d4e767e0df9d7" . "d407380" => base64_decode("ZGF0ZV9jcmVhd" . "GVk"));
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 $_8652ba33e6ffeba02459fa9cbb320851, EventDispatcherInterface $dispatcher)
    {
        $this->acl = $acl;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->repository = $_8652ba33e6ffeba02459fa9cbb320851;
        $this->dispatcher = $dispatcher;
    }
    
    
    
    
    
    
    
    
    
    public function CreateRole(SecurityContext $context, array $_809a58dc73011173c031a53c0b40ef0e) : Role
    {
        if (!$this->acl->CanCreateRole($context)) {
            throw new PermissionException($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_1c460ef93e1d" . "73740faa1305c" . "e7bcbc0"]);
        }
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["na" . "me"] => $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_4d707fab93bebb00bbe" . "69e8159697c90"], $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_28fd57f750dbb5ffb3ffad3a888358" . "a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e8" . "159697c90"], $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_c4d674abe9291be143b224c411958" . "fcf"] => 0, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_f098127274322059a98331869c" . "1b4724"] => false, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["extr" . "anet" . "_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4e259f7b99bbc380" . "aa93bb08a23d9fba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_4d2b763f00ba1e80018" . "79ba79a849269"]($_809a58dc73011173c031a53c0b40ef0e, $_7c7a0774c7447eed1a9b0b8aba163b8f));
        $_809a58dc73011173c031a53c0b40ef0e[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_aa7e860da1acd4e" . "767e0df9d7d40738" . "0"]] = 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["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["role_" . "id"] => $_d1071a032215f0eb5c4a8ef175f7049d->id, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_d3b7f7e78c14a11ff949425c39b9c4" . "7d"] => $_d1071a032215f0eb5c4a8ef175f7049d->name, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_50de2c5f461bce4b2f793c" . "1981a022b8"] => $_d1071a032215f0eb5c4a8ef175f7049d->description, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_28fd57f750dbb5ffb3ffad3a88835" . "8a9"] => $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_64c9177a48c51e010a72189" . "a03443a3d"] . $_d1071a032215f0eb5c4a8ef175f7049d->name . $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_0fa8ac09f5ba99c31dcb832c" . "61e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_ROLE);
        return $_d1071a032215f0eb5c4a8ef175f7049d;
    }
}