<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] = (@$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"] ?: array()) + array("paren" . "t_id" => base64_decode("cGFyZ" . "W50X2" . "lk"), "_4e259f7b99bbc380aa9" . "3bb08a23d9fba" => base64_decode("YXJyYXlfc" . "mVwbGFjZQ" . "=="), "na" . "me" => base64_decode("bmFtZ" . "Q=="), "_1aefddc3a5a9f6a8327be86402" . "f2df2b" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8gY3JlY" . "XRlIGdyb3Vwcw=="), "group_i" . "d" => base64_decode("Z3J" . "vdX" . "Bfa" . "WQ="), "_0fa8ac09f5ba99c31dcb832c" . "61e34b14" => base64_decode("JyB" . "jcm" . "Vhd" . "GVk"), "_4d707fab93bebb00bbe69e8159" . "697c90" => base64_decode(""), "_aa7e860da1acd4e767e0df9d7d" . "407380" => base64_decode("ZGF0ZV9jcmVh" . "dGVk"), "_28fd57f750dbb5" . "ffb3ffad3a88835" . "8a9" => base64_decode("ZGVzY3JpcHRpb" . "24="), "_2176251d6bf95f1260999" . "2c4c4b89cd2" => base64_decode("Z3JvdXBfZGVzY3JpcHRpb24" . "="), "_7e9f8a5975581662858d" . "88b41f28c375" => base64_decode("R3JvdXAg" . "Jw=="), "_f098127274322059a98331869" . "c1b4724" => base64_decode("aW5h" . "Y3Rp" . "dmU="), "extranet" . "_id" => base64_decode("ZXh0cmFuZXRfaWQ" . "="), "_4d2b763f00ba1e8001879ba79a84926" . "9" => base64_decode("YXJyYXlfaW50Z" . "XJzZWN0X2tleQ" . "=="), "_881a4fa77530ca74f2e5c2f780bd49f" . "f" => base64_decode("ZGVmYXV" . "sdF9za2" . "lu"), "_57efdd12171944bad07" . "acaedbab41ce2" => base64_decode("Y3JtX21hbm" . "FnZXIy"), "_9dcc601fde02ee04d2f0fed" . "66d5beb92" => base64_decode("Y3JtX21hbmFn" . "ZXI="), "_28685591a1d64debd044e30" . "74d01b84d" => base64_decode("b3duZXJfaWQ" . "="), "_cfbcaa846f2fe39" . "0f2fa2377af581c3" . "f" => base64_decode("Z3Jv" . "dXBf" . "bmFt" . "ZQ=="));
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["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_1aefddc3a5a9f" . "6a8327be86402f" . "2df2b"]);
        }
        $this->validator->ValidateCreate($attributes);
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["na" . "me"] => $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_4d707fab93" . "bebb00bbe69" . "e8159697c90"], $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_881a4fa77530c" . "a74f2e5c2f780b" . "d49ff"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_f098127274" . "322059a9833" . "1869c1b4724"] => 0, $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["paren" . "t_id"] => 0, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_9dcc601fde0" . "2ee04d2f0fed" . "66d5beb92"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_57efdd12171944bad07aca" . "edbab41ce2"] => null, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_28685591a1" . "d64debd044e" . "3074d01b84d"] => $context->GetUserId(), $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_28fd57f750dbb5ffb3ffad3a888" . "358a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_4d707fab93be" . "bb00bbe69e815" . "9697c90"], $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_aa7e860da1acd4e767e0df9d7d40" . "7380"] => new Date(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["extr" . "anet" . "_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4e259f7b99bbc380aa93bb08a2" . "3d9fba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["grou" . "p_id"] => $_e9208e4fb555ac989f7519e19c1da810->id, $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_cfbcaa846f2f" . "e390f2fa2377a" . "f581c3f"] => $_e9208e4fb555ac989f7519e19c1da810->name, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_2176251d6bf95f12609" . "992c4c4b89cd2"] => $_e9208e4fb555ac989f7519e19c1da810->description, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_28fd57f750dbb5ffb3" . "ffad3a888358a9"] => $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_7e9f8a5975581662858d88b" . "41f28c375"] . $_e9208e4fb555ac989f7519e19c1da810->name . $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0fa8ac0" . "9f5ba99c" . "31dcb832" . "c61e34b1" . "4"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_GROUP);
        return $_e9208e4fb555ac989f7519e19c1da810;
    }
}