<?php
namespace Claromentis\People\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] ?: array()) + array("extran" . "et_id" => base64_decode("ZXh0c" . "mFuZX" . "RfaWQ" . "="), "_57efdd121719" . "44bad07acaedb" . "ab41ce2" => base64_decode("Y3JtX21" . "hbmFnZX" . "Iy"), "_f098127274322059a98" . "331869c1b4724" => base64_decode("aW5hY3RpdmU" . "="), "_28685591a1d64de" . "bd044e3074d01b84" . "d" => base64_decode("b3duZXJf" . "aWQ="), "_7e9f8a59755816628" . "58d88b41f28c375" => base64_decode("R3JvdXAg" . "Jw=="), "_4e259f7b99bbc380aa93bb08a23d9" . "fba" => base64_decode("YXJyYXlfcmVwbGF" . "jZQ=="), "_0fa8ac09f5ba99c31dc" . "b832c61e34b14" => base64_decode("JyBj" . "cmVh" . "dGVk"), "_2176251d6bf95f12609992c4c4b89c" . "d2" => base64_decode("Z3JvdXBfZ" . "GVzY3JpcH" . "Rpb24="), "_1aefddc3a5a9f6a8327be864" . "02f2df2b" => base64_decode("WW91IGRvIG5vdCBoYXZlIHBlcm1pc3Npb24gdG8gY3JlYXRlIGd" . "yb3Vwcw=="), "_4d707fab93bebb00bbe69e81" . "59697c90" => base64_decode(""), "_881a4fa77530ca74f" . "2e5c2f780bd49ff" => base64_decode("ZGVm" . "YXVs" . "dF9z" . "a2lu"), "group_i" . "d" => base64_decode("Z3Jvd" . "XBfaW" . "Q="), "_9dcc601f" . "de02ee04d" . "2f0fed66d" . "5beb92" => base64_decode("Y3JtX2" . "1hbmFn" . "ZXI="), "_28fd57f750dbb5ff" . "b3ffad3a888358a9" => base64_decode("ZGVzY3" . "JpcHRp" . "b24="), "parent" . "_id" => base64_decode("cGFyZW5" . "0X2lk"), "n" . "a" . "m" . "e" => base64_decode("bmFtZ" . "Q=="), "_cfbcaa846f2fe" . "390f2fa2377af5" . "81c3f" => base64_decode("Z3JvdX" . "BfbmFt" . "ZQ=="), "_4d2b763f00ba1e8001879ba" . "79a849269" => base64_decode("YXJyYXlfaW50ZXJzZWN0X" . "2tleQ=="), "_aa7e860da1acd4e76" . "7e0df9d7d407380" => base64_decode("ZGF0ZV9" . "jcmVhdG" . "Vk"));
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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_1aefddc3a5a9f6a8327be" . "86402f2df2b"]);
        }
        $this->validator->ValidateCreate($attributes);
        
        
        $_7c7a0774c7447eed1a9b0b8aba163b8f = [$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["na" . "me"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4d707fab93" . "bebb00bbe69" . "e8159697c90"], $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_881a4fa775" . "30ca74f2e5c" . "2f780bd49ff"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_f098127274322059a98331869c1b47" . "24"] => 0, $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["parent" . "_id"] => 0, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_9dcc601fde02e" . "e04d2f0fed66d5" . "beb92"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_57efdd12171944b" . "ad07acaedbab41ce" . "2"] => null, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_28685591a1d64" . "debd044e3074d0" . "1b84d"] => $context->GetUserId(), $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_28fd57f750dbb5ffb3ffad3a888" . "358a9"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fa" . "b93bebb0" . "0bbe69e8" . "159697c9" . "0"], $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_aa7e860d" . "a1acd4e76" . "7e0df9d7d" . "407380"] => new Date(), $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["extran" . "et_id"] => 0];
        $_809a58dc73011173c031a53c0b40ef0e = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_4e259f7b99bbc3" . "80aa93bb08a23d9" . "fba"]($_7c7a0774c7447eed1a9b0b8aba163b8f, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_4d2b763f00ba1e80" . "01879ba79a849269"]($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["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["group" . "_id"] => $_e9208e4fb555ac989f7519e19c1da810->id, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_cfbcaa846f2fe" . "390f2fa2377af5" . "81c3f"] => $_e9208e4fb555ac989f7519e19c1da810->name, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_2176251d6bf9" . "5f12609992c4c" . "4b89cd2"] => $_e9208e4fb555ac989f7519e19c1da810->description, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_28fd57f750dbb5ffb3ffa" . "d3a888358a9"] => $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_7e9f8a5975" . "581662858d8" . "8b41f28c375"] . $_e9208e4fb555ac989f7519e19c1da810->name . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0fa8ac09f5ba99c" . "31dcb832c61e34b1" . "4"]]);
        $this->dispatcher->dispatch($event, PeopleEventType::ADD_GROUP);
        return $_e9208e4fb555ac989f7519e19c1da810;
    }
}