<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] ?: array()) + array("_f098127274322059a98331869c1b472" . "4" => base64_decode("aW5hY3RpdmU" . "="), "_57efdd1217194" . "4bad07acaedbab" . "41ce2" => base64_decode("Y3JtX21hbmFnZ" . "XIy"), "_1aefddc3a5a9f6a8327be86402f2d" . "f2b" => base64_decode("WW91IGRvIG5vdCBoYX" . "ZlIHBlcm1pc3Npb24g" . "dG8gY3JlYXRlIGdyb3" . "Vwcw=="), "_4d2b763f00ba1e8001" . "879ba79a849269" => base64_decode("YXJyYXlfaW5" . "0ZXJzZWN0X2" . "tleQ=="), "_9dcc601fde02" . "ee04d2f0fed66" . "d5beb92" => base64_decode("Y3JtX21hbmFnZX" . "I="), "_4d707fab93bebb00bbe69e815" . "9697c90" => base64_decode(""), "_881a4fa77530ca74f2e5c2f7" . "80bd49ff" => base64_decode("ZGVmYXV" . "sdF9za2" . "lu"), "_aa7e860da1acd4e767e0df9" . "d7d407380" => base64_decode("ZGF0ZV" . "9jcmVh" . "dGVk"), "_28fd57f750dbb5ffb3ffad3a88" . "8358a9" => base64_decode("ZGVz" . "Y3Jp" . "cHRp" . "b24="), "extran" . "et_id" => base64_decode("ZXh0cmFuZX" . "RfaWQ="), "_28685591a1d64debd" . "044e3074d01b84d" => base64_decode("b3duZXJ" . "faWQ="), "_4e259f7b99bbc380aa93bb0" . "8a23d9fba" => base64_decode("YXJyYXlfcmVw" . "bGFjZQ=="), "n" . "a" . "m" . "e" => base64_decode("bmFtZQ" . "=="), "grou" . "p_id" => base64_decode("Z3Jvd" . "XBfaW" . "Q="), "_7e9f8a5975581662858d88b41" . "f28c375" => base64_decode("R3JvdXAgJw" . "=="), "pa" . "re" . "nt" . "_i" . "d" => base64_decode("cGFyZW50" . "X2lk"), "_cfbcaa84" . "6f2fe390f" . "2fa2377af" . "581c3f" => base64_decode("Z3JvdXBfbmFtZ" . "Q=="), "_0fa8ac09f5ba9" . "9c31dcb832c61e" . "34b14" => base64_decode("JyBjcmVh" . "dGVk"), "_2176251d6bf95f12609992" . "c4c4b89cd2" => base64_decode("Z3JvdXBfZGVzY3Jp" . "cHRpb24="));
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"]["_1aefddc3a5a9f6" . "a8327be86402f2d" . "f2b"]);
        }
        $this->validator->ValidateCreate($attributes);
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["nam" . "e"] => $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4d707fab9" . "3bebb00bbe" . "69e8159697" . "c90"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_881a4fa77530ca74f2e5c2f780bd49f" . "f"] => 0, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_f098127274322059a98331869c1b47" . "24"] => 0, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["parent_i" . "d"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_9dcc601fde02ee04" . "d2f0fed66d5beb92"] => null, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_57efdd12171944bad07a" . "caedbab41ce2"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_28685591a1d64debd044e3" . "074d01b84d"] => $context->GetUserId(), $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_28fd57f750dbb5ffb3ffad3a888358" . "a9"] => $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d707fab93b" . "ebb00bbe69e8" . "159697c90"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_aa7e860da1acd4e767e0df9d7d4" . "07380"] => new Date(), $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["extranet" . "_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_4e259f7" . "b99bbc38" . "0aa93bb0" . "8a23d9fb" . "a"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["group" . "_id"] => $_e9208e4fb555ac989f7519e19c1da810->id, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_cfbcaa846f2fe390f2fa2377af5" . "81c3f"] => $_e9208e4fb555ac989f7519e19c1da810->name, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_2176251d6bf95f12609992c4c4b89cd" . "2"] => $_e9208e4fb555ac989f7519e19c1da810->description, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_28fd57f750dbb5ffb3ffad" . "3a888358a9"] => $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_7e9f8a5" . "97558166" . "2858d88b" . "41f28c37" . "5"] . $_e9208e4fb555ac989f7519e19c1da810->name . $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_0fa8ac09f5ba99c31dcb832c61" . "e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_GROUP);
        return $_e9208e4fb555ac989f7519e19c1da810;
    }
}