<?php
namespace Claromentis\Pages\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] ?: array()) + array("_11cad0367c939d76c4f" . "877581c151a10" => base64_decode("eQ" . "=="), "_f9696953938d5" . "eb0c93b1562b60" . "ba3a6" => base64_decode("eA" . "=="), "_3fe79c1c3dbe98dac2" . "52d4b18cccf315" => base64_decode("dGlsZV9pZ" . "A=="), "_7878552e24168199" . "99092641d19320ae" => base64_decode("aGVpZ2" . "h0"), "_4ed3ada46a23e917ec1" . "dd41d39de09aa" => base64_decode("cGFnZXMubGF5b3V0L" . "m5vX3Blcm1pc3Npb2" . "4="), "_0c5123aa744f69bbc0e8" . "b3ea2f6e847d" => base64_decode("bG1" . "zZw" . "=="), "_795cf2d94dc58d" . "02d01c23e25295b" . "2ad" => base64_decode("d2lkdG" . "g="));
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Pages\Exception\AccessDeniedException;
use Claromentis\Pages\Lock\LockService;
use Claromentis\Pages\PagesAcl;
use Claromentis\Pages\Repository\PagesRepository;
use Claromentis\Pages\Repository\TileProvider;




class SaveGeometry
{
    protected $pages_repo;
    protected $tile_provider;
    protected $acl;
    protected $locks;
    public function __construct(PagesRepository $pages_repo, TileProvider $tile_provider, PagesAcl $acl, LockService $_9cd4b2152729fd679e63852ebc623594)
    {
        $this->pages_repo = $pages_repo;
        $this->tile_provider = $tile_provider;
        $this->acl = $acl;
        $this->locks = $_9cd4b2152729fd679e63852ebc623594;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function Save(SecurityContext $context, $_720c0c64bd5b02debfb65448083be0bf, $_490a24fd65ef2b3ccfc5941892ef496b)
    {
        $_221da17e3055fae8d3ff516b832a5f3b = $this->pages_repo->GetById($_720c0c64bd5b02debfb65448083be0bf);
        
        
        if (!$this->acl->CanEditPage($context, $_221da17e3055fae8d3ff516b832a5f3b)) {
            throw new AccessDeniedException($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_0c5123aa744f69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_4ed3ada46a23e91" . "7ec1dd41d39de09a" . "a"]));
        }
        $this->locks->Extend($_221da17e3055fae8d3ff516b832a5f3b->url_id, $context->GetUserId());
        $_019b08c82680fcd8e809591bdfa5c097 = [];
        foreach ($_490a24fd65ef2b3ccfc5941892ef496b as $tile) {
            $_019b08c82680fcd8e809591bdfa5c097[] = $tile[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_3fe79c1c3dbe98dac252d4b18cccf31" . "5"]];
        }
        $this->tile_provider->SoftDeleteMissing($_720c0c64bd5b02debfb65448083be0bf, $_019b08c82680fcd8e809591bdfa5c097);
        foreach ($_490a24fd65ef2b3ccfc5941892ef496b as $tile) {
            $this->tile_provider->SaveGeometry($_720c0c64bd5b02debfb65448083be0bf, $tile[$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_3fe79c1c3dbe9" . "8dac252d4b18cc" . "cf315"]], $tile[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_f9696953938d5eb0c93" . "b1562b60ba3a6"]], $tile[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_11cad0367c939d" . "76c4f877581c151" . "a10"]], $tile[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_795cf2d9" . "4dc58d02d" . "01c23e252" . "95b2ad"]], $tile[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_7878552e2416819999" . "092641d19320ae"]]);
        }
    }
}