<?php
namespace Claromentis\Pages\TrashCan;

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"] ?: array()) + array("_bc4d90d74ec71b03" . "3b521d94df2593cb" => base64_decode("ZnVs" . "bF91" . "cmw="), "_b9dfe905" . "0ce590520" . "95473d712" . "252687" => base64_decode("cGFnZXMudXNl" . "X2Nhc2UuZGVs" . "ZXRlX21lbnVp" . "dGVt"), "_fef4d8bc91d2ee692" . "c4472ab020a8809" => base64_decode("VHJhc2hPYmplY3RNZW51SXRlbTo6Q3JlYXRlRnJ" . "vbU9iamVjdCgpIGFjY2VwdHMgb25seSBvYmplY3" . "Qgb2YgY2xhc3MgTWVudUl0ZW0="), "_a591754a8ddcdbda" . "9c80f1db4d911e14" => base64_decode("aXNfbnVs" . "bA=="), "_ef15677afc048bfbd52dad8cce" . "a88222" => base64_decode("cGFnZXMudHJhc2gucG" . "FnZV9pdGVt"), "_1dd1262b8576e1f35064bbd227ec4fe" . "1" => base64_decode("cGFnZXMubWVudV9p" . "dGVtX3JlcG9zaXRv" . "cnk="), "_feb9037589" . "181bc30fa0f" . "1cf78b9f056" => base64_decode("dG" . "l0" . "bG" . "U="), "_1774daf8217e" . "b41295b1c5c7f" . "62288a8" => base64_decode("cGFnZXMuc" . "2l0ZV9yZX" . "Bvc2l0b3J" . "5"), "_0c5123aa744f69bbc0e8b3ea" . "2f6e847d" => base64_decode("bG1z" . "Zw=="));
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["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_1774daf8" . "217eb4129" . "5b1c5c7f6" . "2288a8"]};
        $this->menu_item_repository = Services::I()->{$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_1dd1262b8576e1f35064bbd227ec" . "4fe1"]};
        $this->aggregation = Perm::AGGREGATION_PAGES_PAGE;
        if (!$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_a591754a8ddcdbda9c80f1db4d911e1" . "4"]($_b15aac3aa29c10ea6d1228f58cb9a7e8) && $_b15aac3aa29c10ea6d1228f58cb9a7e8 instanceof MenuItem) {
            $this->CreateFromObject($_b15aac3aa29c10ea6d1228f58cb9a7e8);
        }
    }
    public function CreateFromObject($_b15aac3aa29c10ea6d1228f58cb9a7e8)
    {
        if (!$_b15aac3aa29c10ea6d1228f58cb9a7e8 instanceof MenuItem) {
            throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_fef4d8bc91d2ee692c447" . "2ab020a8809"]);
        }
        $_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["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_feb9037589181bc30fa0f1cf78" . "b9f056"]);
        $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["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_bc4d90d74ec71b033b521d94df2593" . "cb"]), 300);
        } else {
            $this->description = $this->cla_text->TrimLongString($_b15aac3aa29c10ea6d1228f58cb9a7e8->link_url, 300);
        }
    }
    public function GetObjectTypeName()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_0c5123aa744f69bbc0" . "e8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_ef15677afc048bfbd" . "52dad8ccea88222"]);
    }
    
    
    
    
    
    
    
    
    
    public function DeleteCompletely() : bool
    {
        
        
        $use_case = Services::I()->{$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_b9dfe9050ce5905209" . "5473d712252687"]};
        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;
    }
}