<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_57efdd12171944bad07acaed" . "bab41ce2" => base64_decode("Y3JtX21hbmFnZXI" . "y"), "_4d2b763f00ba1e8001879ba79a8" . "49269" => base64_decode("YXJyYXlfaW50ZXJzZWN0X2t" . "leQ=="), "group_" . "id" => base64_decode("Z3JvdXBfa" . "WQ="), "_2176251d6" . "bf95f12609" . "992c4c4b89" . "cd2" => base64_decode("Z3JvdXBfZGVzY3Jp" . "cHRpb24="), "_f098127274322059a983" . "31869c1b4724" => base64_decode("aW5hY3Rpd" . "mU="), "nam" . "e" => base64_decode("bmF" . "tZQ" . "=="), "_4e259f7b99bbc380aa93bb08a23d9fb" . "a" => base64_decode("YXJyYXl" . "fcmVwbG" . "FjZQ=="), "_28685591a1d64debd044e30" . "74d01b84d" => base64_decode("b3d" . "uZX" . "Jfa" . "WQ="), "_7e9f8a597" . "5581662858" . "d88b41f28c" . "375" => base64_decode("R3Jvd" . "XAgJw" . "=="), "_9dcc601fde02ee04d2f0fe" . "d66d5beb92" => base64_decode("Y3JtX21h" . "bmFnZXI="), "_28fd57f750d" . "bb5ffb3ffad3" . "a888358a9" => base64_decode("ZGVzY3Jp" . "cHRpb24="), "_cfbcaa846f2fe390f2fa2377a" . "f581c3f" => base64_decode("Z3JvdXB" . "fbmFtZQ" . "=="), "_aa7e860da1acd4e767e0d" . "f9d7d407380" => base64_decode("ZGF0ZV9jc" . "mVhdGVk"), "extran" . "et_id" => base64_decode("ZXh0cmFuZXRfaWQ" . "="), "_881a4fa77530ca74" . "f2e5c2f780bd49ff" => base64_decode("ZGVmYXVsdF" . "9za2lu"), "_0fa8ac09f5ba99c31dcb83" . "2c61e34b14" => base64_decode("JyBjc" . "mVhdG" . "Vk"), "par" . "ent" . "_id" => base64_decode("cGFyZW" . "50X2lk"), "_4d707fab93be" . "bb00bbe69e815" . "9697c90" => base64_decode(""), "_1aefddc3a5a9f6a8327be86402f2df" . "2b" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb2" . "4gdG8gY3JlYXRlIGdyb3Vwcw=="));
use Analogue\ORM\Exceptions\MappingException;
use Claromentis\Core\Acl\PermOClass;
use Claromentis\Core\Event\EventDispatcher;
use Claromentis\Core\Event\GenericEvent;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\Group;
use Claromentis\People\Event\PeopleEventType;
use Claromentis\People\Exception\PermissionException;
use Claromentis\People\Exception\ValidationException;
use Claromentis\People\PeopleAcl;
use Claromentis\People\Repository\GroupRepository;
use Claromentis\People\Validator\GroupValidator;
use Date;
class CreateGroup
{
    
    
    private $acl;
    
    
    private $repo;
    
    
    private $dispatcher;
    
    
    private $validator;
    
    
    private $lmsg;
    public function __construct(PeopleAcl $acl, GroupRepository $repo, EventDispatcher $dispatcher, GroupValidator $_24c8d051c033d19c2c97cdc3d7098b1b, Lmsg $lmsg)
    {
        $this->acl = $acl;
        $this->repo = $repo;
        $this->dispatcher = $dispatcher;
        $this->validator = $_24c8d051c033d19c2c97cdc3d7098b1b;
        $this->lmsg = $lmsg;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function CreateGroup(SecurityContext $context, array $attributes) : Group
    {
        
        
        if (!$this->acl->CanCreateGroup($context)) {
            throw new PermissionException($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_1aefddc3a5a9f6a8327be86402f" . "2df2b"]);
        }
        $this->validator->ValidateCreate($attributes);
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["n" . "a" . "m" . "e"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_4d707fab93bebb00bbe69e8159" . "697c90"], $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_881a4fa77530ca74f2e5c2f" . "780bd49ff"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_f098127274322059a9833" . "1869c1b4724"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["pare" . "nt_i" . "d"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_9dcc601fde02ee04d2" . "f0fed66d5beb92"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_57efdd12171944bad07acaedbab4" . "1ce2"] => null, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_28685591a1d64debd044e3074d" . "01b84d"] => $context->GetUserId(), $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_28fd57f" . "750dbb5f" . "fb3ffad3" . "a888358a" . "9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fab93bebb" . "00bbe69e8159697" . "c90"], $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_aa7e860da1acd4e767e0" . "df9d7d407380"] => new Date(), $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["extran" . "et_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_4e259f7b99" . "bbc380aa93b" . "b08a23d9fba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_4d2b763f00ba1" . "e8001879ba79a8" . "49269"]($attributes, $_7c7a0774c7447eed1a9b0b8aba163b8f));
        $_e9208e4fb555ac989f7519e19c1da810 = new Group();
        $_e9208e4fb555ac989f7519e19c1da810->fill($_809a58dc73011173c031a53c0b40ef0e);
        
        
        $this->validator->Validate($_e9208e4fb555ac989f7519e19c1da810);
        $this->repo->store($_e9208e4fb555ac989f7519e19c1da810);
        $this->acl->AddObject($context, PermOClass::GROUP, $_e9208e4fb555ac989f7519e19c1da810->id);
        
        
        $event = new GenericEvent($_e9208e4fb555ac989f7519e19c1da810, [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["group" . "_id"] => $_e9208e4fb555ac989f7519e19c1da810->id, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_cfbcaa846f2fe390f2fa2377af581c" . "3f"] => $_e9208e4fb555ac989f7519e19c1da810->name, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_2176251d6bf95f12609992c4c4b89" . "cd2"] => $_e9208e4fb555ac989f7519e19c1da810->description, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_28fd57f750dbb5ffb3" . "ffad3a888358a9"] => $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_7e9f8a5975581" . "662858d88b41f2" . "8c375"] . $_e9208e4fb555ac989f7519e19c1da810->name . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_0fa8ac09f5ba99c31dcb83" . "2c61e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_GROUP);
        return $_e9208e4fb555ac989f7519e19c1da810;
    }
}