<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] = (@$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] ?: array()) + array("group_i" . "d" => base64_decode("Z3JvdXBfaW" . "Q="), "parent_" . "id" => base64_decode("cGFyZW5" . "0X2lk"), "_881a4fa77530ca74f2e5" . "c2f780bd49ff" => base64_decode("ZGVmYXVsdF9za2" . "lu"), "extr" . "anet" . "_id" => base64_decode("ZXh0cmFuZX" . "RfaWQ="), "_9dcc601fde02ee04" . "d2f0fed66d5beb92" => base64_decode("Y3JtX21hbmF" . "nZXI="), "_cfbcaa846f2" . "fe390f2fa237" . "7af581c3f" => base64_decode("Z3JvdXBfbmF" . "tZQ=="), "_f098127274322059a98331869c" . "1b4724" => base64_decode("aW5h" . "Y3Rp" . "dmU="), "_57efdd12171944bad07acaedbab41" . "ce2" => base64_decode("Y3JtX21hbmFnZX" . "Iy"), "n" . "a" . "m" . "e" => base64_decode("bmFt" . "ZQ=="), "_28685591a1d64debd044e3074d0" . "1b84d" => base64_decode("b3duZXJfaW" . "Q="), "_aa7e860da1acd4e767e0df9d7d4073" . "80" => base64_decode("ZGF0Z" . "V9jcm" . "VhdGV" . "k"), "_1aefddc3a5a9f6a8327be8" . "6402f2df2b" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8gY3JlYXRlIGdyb3" . "Vwcw=="), "_4e259f7b99bbc380aa93bb08a23d" . "9fba" => base64_decode("YXJyYXlfcmVwb" . "GFjZQ=="), "_2176251d6bf95f12609992c4c4b89c" . "d2" => base64_decode("Z3JvdXBfZGVzY3JpcH" . "Rpb24="), "_7e9f8a5975581662858d88b41f28" . "c375" => base64_decode("R3Jv" . "dXAg" . "Jw=="), "_0fa8ac09f5ba" . "99c31dcb832c6" . "1e34b14" => base64_decode("JyBjcmVhdGV" . "k"), "_28fd57f750dbb" . "5ffb3ffad3a888" . "358a9" => base64_decode("ZGVzY3JpcHRpb" . "24="), "_4d2b763f" . "00ba1e800" . "1879ba79a" . "849269" => base64_decode("YXJyYXlf" . "aW50ZXJz" . "ZWN0X2tl" . "eQ=="), "_4d707fab93beb" . "b00bbe69e81596" . "97c90" => base64_decode(""));
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["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_1aefddc3a5a9f6a8327be86402f2df" . "2b"]);
        }
        $this->validator->ValidateCreate($attributes);
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["nam" . "e"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_4d707fa" . "b93bebb0" . "0bbe69e8" . "159697c9" . "0"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_881a4fa77530ca74f2e5" . "c2f780bd49ff"] => 0, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_f09812727432" . "2059a98331869" . "c1b4724"] => 0, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["parent" . "_id"] => 0, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_9dcc601fde02ee04d2f0fed6" . "6d5beb92"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_57efdd12171944bad07acaed" . "bab41ce2"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_28685591a1d64deb" . "d044e3074d01b84d"] => $context->GetUserId(), $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_28fd57f750dbb5ffb3ffad" . "3a888358a9"] => $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_4d707fab93beb" . "b00bbe69e81596" . "97c90"], $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_aa7e860d" . "a1acd4e76" . "7e0df9d7d" . "407380"] => new Date(), $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["extranet_i" . "d"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_4e259f7b99bbc380aa93bb08a23d9f" . "ba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["gr" . "ou" . "p_" . "id"] => $_e9208e4fb555ac989f7519e19c1da810->id, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_cfbcaa846f2fe390f2fa2377af581" . "c3f"] => $_e9208e4fb555ac989f7519e19c1da810->name, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_2176251d6bf95f12609992c4" . "c4b89cd2"] => $_e9208e4fb555ac989f7519e19c1da810->description, $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_28fd57f750db" . "b5ffb3ffad3a8" . "88358a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_7e9f8a5975581662858" . "d88b41f28c375"] . $_e9208e4fb555ac989f7519e19c1da810->name . $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_0fa8ac09f5" . "ba99c31dcb8" . "32c61e34b14"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_GROUP);
        return $_e9208e4fb555ac989f7519e19c1da810;
    }
}