<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] ?: array()) + array("_881a4fa77530ca74f2e5c2f" . "780bd49ff" => base64_decode("ZGVmYXV" . "sdF9za2" . "lu"), "pare" . "nt_i" . "d" => base64_decode("cGFyZW50X2" . "lk"), "_7e9f8a5975581662" . "858d88b41f28c375" => base64_decode("R3JvdXAgJw=" . "="), "_9dcc601fde02ee04d2f0fed66d5beb" . "92" => base64_decode("Y3JtX21hb" . "mFnZXI="), "_cfbcaa846f2fe" . "390f2fa2377af5" . "81c3f" => base64_decode("Z3JvdXBfbmFtZQ=" . "="), "_4d707fab93bebb00bbe69e8159697c" . "90" => base64_decode(""), "_4d2b763f00ba1e80" . "01879ba79a849269" => base64_decode("YXJyYXlfaW50" . "ZXJzZWN0X2tl" . "eQ=="), "_2176251d6bf95f12609992c4c" . "4b89cd2" => base64_decode("Z3JvdXBfZG" . "VzY3JpcHRp" . "b24="), "_0fa8ac09f5ba99c31dcb" . "832c61e34b14" => base64_decode("JyBjcmV" . "hdGVk"), "gr" . "ou" . "p_" . "id" => base64_decode("Z3JvdXB" . "faWQ="), "_28685591a1d64debd044e3074" . "d01b84d" => base64_decode("b3duZ" . "XJfaW" . "Q="), "extranet" . "_id" => base64_decode("ZXh0cmFuZXR" . "faWQ="), "_28fd57f750dbb5ffb3ffad3a88835" . "8a9" => base64_decode("ZGVzY3Jp" . "cHRpb24="), "_f0981272743" . "22059a983318" . "69c1b4724" => base64_decode("aW5hY3Rp" . "dmU="), "_4e259f7b99" . "bbc380aa93b" . "b08a23d9fba" => base64_decode("YXJyYXlfcm" . "VwbGFjZQ=="), "_1aefddc3a5a" . "9f6a8327be86" . "402f2df2b" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8" . "gY3JlYXRlIGdyb3Vwcw=="), "_aa7e860da1acd" . "4e767e0df9d7d4" . "07380" => base64_decode("ZGF0" . "ZV9j" . "cmVh" . "dGVk"), "na" . "me" => base64_decode("bmFtZ" . "Q=="), "_57efdd12171944bad07acaedbab" . "41ce2" => base64_decode("Y3JtX21h" . "bmFnZXIy"));
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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_1aefddc3a5a9" . "f6a8327be8640" . "2f2df2b"]);
        }
        $this->validator->ValidateCreate($attributes);
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["na" . "me"] => $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d707fab93bebb00bbe69e8159697" . "c90"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_881a4fa77530ca74f" . "2e5c2f780bd49ff"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_f0981272743" . "22059a983318" . "69c1b4724"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["par" . "ent" . "_id"] => 0, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_9dcc601fde02ee04d2" . "f0fed66d5beb92"] => null, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_57efdd12171944bad07ac" . "aedbab41ce2"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_2868559" . "1a1d64de" . "bd044e30" . "74d01b84" . "d"] => $context->GetUserId(), $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_28fd57f750dbb5ffb3" . "ffad3a888358a9"] => $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e81596" . "97c90"], $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_aa7e860da1acd4e767e0df9d7d4073" . "80"] => new Date(), $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["extran" . "et_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_4e259f7b9" . "9bbc380aa9" . "3bb08a23d9" . "fba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_4d2b763f00ba1e8001879ba79a849" . "269"]($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["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["group_" . "id"] => $_e9208e4fb555ac989f7519e19c1da810->id, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_cfbcaa846" . "f2fe390f2f" . "a2377af581" . "c3f"] => $_e9208e4fb555ac989f7519e19c1da810->name, $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_2176251d6bf95f12609992c" . "4c4b89cd2"] => $_e9208e4fb555ac989f7519e19c1da810->description, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_28fd57f750" . "dbb5ffb3ffa" . "d3a888358a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_7e9f8a5975581662858d88b41f28c" . "375"] . $_e9208e4fb555ac989f7519e19c1da810->name . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_0fa8ac09f5ba99c31dcb8" . "32c61e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_GROUP);
        return $_e9208e4fb555ac989f7519e19c1da810;
    }
}