<?php
namespace Claromentis\Pages\UseCase;

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] ?: array()) + array("u" . "r" . "l" => base64_decode("dX" . "Js"), "_37c16e388326602306bacde35d5eba0" . "9" => base64_decode("aXNQ" . "YWdl" . "cw=="), "_dc7c5c82cc9" . "76ae7af1dd13" . "efd610c37" => base64_decode("YXJyYXlfdW5" . "zaGlmdA=="), "_0c5123aa744f69b" . "bc0e8b3ea2f6e847" . "d" => base64_decode("bG1zZw" . "=="), "na" . "me" => base64_decode("bmFtZQ=" . "="), "_16fbf5e7b2" . "1e27eecbd46" . "2ac8622e368" => base64_decode("cGFnZXMubWVudS" . "5ub192aWV3X3Jp" . "Z2h0cw=="));
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Pages\Exception\AccessDeniedException;
use Claromentis\Pages\Model\Page;
use Claromentis\Pages\PagesAcl;
use Claromentis\Pages\Repository\MenuItemRepository;
use Claromentis\Pages\Repository\PagesRepository;
use Claromentis\Pages\Repository\UrlRepository;




class GetPageBreadcrumb
{
    protected $url_repository;
    protected $menu_repository;
    protected $page_repository;
    protected $acl;
    public function __construct(PagesAcl $acl, UrlRepository $_0ffc8e5433da0b1c27f79e871fb130bc, MenuItemRepository $_068f775abfb0a9ebf75eaa65d57173c2, PagesRepository $_d046fa728e87139730b64d892eb2d204)
    {
        $this->acl = $acl;
        $this->url_repository = $_0ffc8e5433da0b1c27f79e871fb130bc;
        $this->menu_repository = $_068f775abfb0a9ebf75eaa65d57173c2;
        $this->page_repository = $_d046fa728e87139730b64d892eb2d204;
    }
    
    
    
    
    
    
    
    
    
    
    public function GetBreadcrumbForPage(SecurityContext $context, Page $_221da17e3055fae8d3ff516b832a5f3b)
    {
        if (!$this->acl->CanViewPage($context, $_221da17e3055fae8d3ff516b832a5f3b->id)) {
            throw new AccessDeniedException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_0c5123aa7" . "44f69bbc0e" . "8b3ea2f6e8" . "47d"]($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_16fbf5e7b21e27eecbd462ac862" . "2e368"]));
        }
        return $this->GetBreadcrumbForPageNoPerms($_221da17e3055fae8d3ff516b832a5f3b);
    }
    
    
    
    
    
    
    
    
    public function GetBreadcrumbForPageNoPerms(Page $_221da17e3055fae8d3ff516b832a5f3b)
    {
        $url = $this->url_repository->GetByPageId($_221da17e3055fae8d3ff516b832a5f3b->GetId());
        $_56215161cab963ee6e3f7a77dbd5feee = $this->menu_repository->GetByUrlId($url->id);
        $_028c56e9753e5e2b616127818a6b7f8d = [[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["u" . "r" . "l"] => $url->GetUrl(), $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["na" . "me"] => $_221da17e3055fae8d3ff516b832a5f3b->GetTitle(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_37c16e388326602306bacd" . "e35d5eba09"] => true]];
        
        
        for ($_644606ca74c2c5245559d17aac5ed202 = 0; $_644606ca74c2c5245559d17aac5ed202 < 2; $_644606ca74c2c5245559d17aac5ed202++) {
            if ($_56215161cab963ee6e3f7a77dbd5feee && $_56215161cab963ee6e3f7a77dbd5feee->parent_id > 0) {
                $_56215161cab963ee6e3f7a77dbd5feee = $this->menu_repository->GetById($_56215161cab963ee6e3f7a77dbd5feee->parent_id);
                $url = $this->url_repository->GetById($_56215161cab963ee6e3f7a77dbd5feee->url_id);
                $_221da17e3055fae8d3ff516b832a5f3b = $this->page_repository->GetById($url->active_page_id);
                $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_dc7c5c8" . "2cc976ae" . "7af1dd13" . "efd610c3" . "7"]($_028c56e9753e5e2b616127818a6b7f8d, [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["u" . "r" . "l"] => $url->GetUrl(), $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["na" . "me"] => $_221da17e3055fae8d3ff516b832a5f3b->GetTitle()]);
            }
        }
        return $_028c56e9753e5e2b616127818a6b7f8d;
    }
}