<?php
namespace Claromentis\Pages\TrashCan;

$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] ?: array()) + array("_0c5123aa744f69bbc0e8b3ea2f6e84" . "7d" => base64_decode("bG1z" . "Zw=="), "_feb9037589181bc30fa0f1cf78" . "b9f056" => base64_decode("dGl" . "0bG" . "U="), "_1dd1262b8576e1f35064" . "bbd227ec4fe1" => base64_decode("cGFnZXMubWVudV9pdGVtX3JlcG9z" . "aXRvcnk="), "_fef4d8bc91d" . "2ee692c4472a" . "b020a8809" => base64_decode("VHJhc2hPYmplY3RNZW51SXRlbTo6Q3JlYXRlRnJvbU9iamVjdCgpIGFjY2VwdHMgb25seSBvYm" . "plY3Qgb2YgY2xhc3MgTWVudUl0ZW0="), "_bc4d90d7" . "4ec71b033" . "b521d94df" . "2593cb" => base64_decode("ZnVsb" . "F91cm" . "w="), "_a591754a8ddc" . "dbda9c80f1db4" . "d911e14" => base64_decode("aXNfbn" . "VsbA=="), "_b9dfe905" . "0ce590520" . "95473d712" . "252687" => base64_decode("cGFnZXMudXN" . "lX2Nhc2UuZG" . "VsZXRlX21lb" . "nVpdGVt"), "_ef15677afc048bfbd52dad8ccea8" . "8222" => base64_decode("cGFnZXMu" . "dHJhc2gu" . "cGFnZV9p" . "dGVt"), "_1774daf8217eb412" . "95b1c5c7f62288a8" => base64_decode("cGFnZXMu" . "c2l0ZV9y" . "ZXBvc2l0" . "b3J5"));
use Claromentis\Core\Services;
use Claromentis\Core\TextUtil\ClaText;
use Claromentis\Pages\Exception\AccessDeniedException;
use Claromentis\Pages\Model\MenuItem;
use Claromentis\Pages\Perm;
use Claromentis\Pages\Repository\MenuItemRepository;
use Claromentis\Pages\Repository\SiteRepository;
use Claromentis\Pages\Repository\UrlRepository;
use Claromentis\Pages\UseCase;
class TrashObjectMenuItem extends TrashObjectPages
{
    protected ClaText $cla_text;
    protected UrlRepository $url_repository;
    protected SiteRepository $site_repository;
    protected MenuItemRepository $menu_item_repository;
    
    
    
    
    
    
    public function __construct($_b15aac3aa29c10ea6d1228f58cb9a7e8 = null)
    {
        $this->cla_text = Services::I()->{ClaText::class};
        $this->url_repository = Services::I()->{UrlRepository::class};
        $this->site_repository = Services::I()->{$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_1774daf8217eb41295b" . "1c5c7f62288a8"]};
        $this->menu_item_repository = Services::I()->{$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_1dd1262b8576e1f35064bbd227" . "ec4fe1"]};
        $this->aggregation = Perm::AGGREGATION_PAGES_PAGE;
        if (!$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_a591754a8ddcdbda9c80f1db4d911e1" . "4"]($_b15aac3aa29c10ea6d1228f58cb9a7e8) && $_b15aac3aa29c10ea6d1228f58cb9a7e8 instanceof MenuItem) {
            $this->CreateFromObject($_b15aac3aa29c10ea6d1228f58cb9a7e8);
        }
    }
    public function CreateFromObject($_b15aac3aa29c10ea6d1228f58cb9a7e8)
    {
        if (!$_b15aac3aa29c10ea6d1228f58cb9a7e8 instanceof MenuItem) {
            throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_fef4d8bc91d2ee692c4472ab02" . "0a8809"]);
        }
        $_ad6d1395fad94fb16ed12d8007727518 = $this->site_repository->Get($_b15aac3aa29c10ea6d1228f58cb9a7e8->site_id);
        $this->site_id = $_b15aac3aa29c10ea6d1228f58cb9a7e8->site_id;
        $this->obj_id = $_b15aac3aa29c10ea6d1228f58cb9a7e8->id;
        $this->title = $this->cla_text->TrimLongString($_b15aac3aa29c10ea6d1228f58cb9a7e8->title, 50);
        $this->orig_location = $_ad6d1395fad94fb16ed12d8007727518->GetProperty($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_feb9037589181bc30fa0f1" . "cf78b9f056"]);
        $this->type = (int) $_b15aac3aa29c10ea6d1228f58cb9a7e8->type === MenuItem::LINK_TYPE_PAGE ? TrashObjectPages::TRASH_TYPE_PAGE : TrashObjectPages::TRASH_TYPE_LINK;
        if ((int) $_b15aac3aa29c10ea6d1228f58cb9a7e8->type === MenuItem::LINK_TYPE_PAGE) {
            $url = $this->url_repository->Get($_b15aac3aa29c10ea6d1228f58cb9a7e8->url_id);
            $this->description = $this->cla_text->TrimLongString($url->GetProperty($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_bc4d90d74ec71b033b521d94df2" . "593cb"]), 300);
        } else {
            $this->description = $this->cla_text->TrimLongString($_b15aac3aa29c10ea6d1228f58cb9a7e8->link_url, 300);
        }
    }
    public function GetObjectTypeName()
    {
        return $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0c5123aa744f69bbc0e8b3ea2f6e" . "847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_ef15677afc048b" . "fbd52dad8ccea88" . "222"]);
    }
    
    
    
    
    
    
    
    
    
    public function DeleteCompletely() : bool
    {
        
        
        $use_case = Services::I()->{$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_b9dfe9050ce59052095473d71225" . "2687"]};
        try {
            $_d43c6db6d25c2749f65bc7bc28bd8df3 = $this->menu_item_repository->GetById($this->obj_id);
            
            
            if ($_d43c6db6d25c2749f65bc7bc28bd8df3 === null) {
                return false;
            }
            $use_case->FullDelete($_d43c6db6d25c2749f65bc7bc28bd8df3);
        } catch (AccessDeniedException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            return false;
        }
        return true;
    }
}