<?php
namespace Claromentis\Pages\UseCase;

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("_1cc3b1c5f4" . "ee4a88fe28f" . "58478c4285e" => base64_decode("Tm8gcmlnaHRzIHRvIGFkZCB0aWxlcyB0byB0aGlzIHBhZ" . "2U="), "_f9696953938d5eb0c93b" . "1562b60ba3a6" => base64_decode("eA" . "=="), "_795cf2d94" . "dc58d02d01" . "c23e25295b" . "2ad" => base64_decode("d2lkdG" . "g="), "_11cad0367c939d" . "76c4f877581c151" . "a10" => base64_decode("eQ" . "=="), "_7878552e24168199990" . "92641d19320ae" => base64_decode("aG" . "Vp" . "Z2" . "h0"));
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["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_1cc3b1c5f4ee4a88f" . "e28f58478c4285e"]);
        }
        $tile = new Tile();
        $tile->class_key = $_d08d3cd4942ca428d7c33be8fa7cdb8d;
        $tile->x = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_f969695393" . "8d5eb0c93b1" . "562b60ba3a6"], 0);
        $tile->y = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_11cad0367c93" . "9d76c4f877581" . "c151a10"], 0);
        $tile->width = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_795cf2d94dc58d02" . "d01c23e25295b2ad"], 0);
        $tile->height = (int) ArrayUtil::getScalarValue($_490a24fd65ef2b3ccfc5941892ef496b, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_7878552e24168" . "19999092641d19" . "320ae"], 0);
        if ($options !== null && !$options->IsEmpty()) {
            $tile->SetOptionsArray($options);
        }
        $_ff8e1002d7b90203619169f5f31a3868 = $this->tile_provider->AddTile($tile, $_221da17e3055fae8d3ff516b832a5f3b->id);
        return $_ff8e1002d7b90203619169f5f31a3868;
    }
}