<?php
namespace Claromentis\Pages\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] = (@$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] ?: array()) + array("_1cc3b1c5f4ee4a88fe28f58478c" . "4285e" => base64_decode("Tm8gcmlnaHRzIHRvIGFkZCB0aWxlcyB0byB0a" . "GlzIHBhZ2U="), "_f9696953938d5eb0c93b1562b60ba" . "3a6" => base64_decode("eA" . "=="), "_11cad036" . "7c939d76c" . "4f877581c" . "151a10" => base64_decode("e" . "Q" . "=" . "="), "_7878552e2416819999092641d19320a" . "e" => base64_decode("aGV" . "pZ2" . "h0"), "_795cf2d94dc58d02" . "d01c23e25295b2ad" => base64_decode("d2lkdGg" . "="));
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Core\Util\ArrayUtil;
use Claromentis\Pages\Exception\AccessDeniedException;
use Claromentis\Pages\Model\OptionsArray;
use Claromentis\Pages\Model\Page;
use Claromentis\Pages\Model\Tile;
use Claromentis\Pages\PagesAcl;
use Claromentis\Pages\Repository\TileProvider;




class AddTile
{
    protected $tile_provider;
    protected $acl;
    public function __construct(TileProvider $tile_provider, PagesAcl $acl)
    {
        $this->tile_provider = $tile_provider;
        $this->acl = $acl;
    }
    public function AddNewTile(SecurityContext $context, Page $_221da17e3055fae8d3ff516b832a5f3b, $_d08d3cd4942ca428d7c33be8fa7cdb8d, $_490a24fd65ef2b3ccfc5941892ef496b = [], OptionsArray $options = null)
    {
        if (!$this->acl->CanEditPage($context, $_221da17e3055fae8d3ff516b832a5f3b)) {
            throw new AccessDeniedException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_1cc3b1c5f4" . "ee4a88fe28f" . "58478c4285e"]);
        }
        $tile = new Tile();
        $tile->class_key = $_d08d3cd4942ca428d7c33be8fa7cdb8d;
        $tile->x = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_f9696953938d5eb0c93b1" . "562b60ba3a6"], 0);
        $tile->y = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_11cad0367c939d76c4f877581c151a" . "10"], 0);
        $tile->width = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_795cf2d94dc58d02d0" . "1c23e25295b2ad"], 0);
        $tile->height = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_7878552e2416819" . "999092641d19320a" . "e"], 0);
        if ($options !== null && !$options->IsEmpty()) {
            $tile->SetOptionsArray($options);
        }
        $_ff8e1002d7b90203619169f5f31a3868 = $this->tile_provider->AddTile($tile, $_221da17e3055fae8d3ff516b832a5f3b->id);
        return $_ff8e1002d7b90203619169f5f31a3868;
    }
}