<?php
namespace Claromentis\Pages\UseCase;

$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] = (@$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"] ?: array()) + array("_dc7c5c82cc976ae7af" . "1dd13efd610c37" => base64_decode("YXJyYXlfdW5z" . "aGlmdA=="), "n" . "a" . "m" . "e" => base64_decode("bmFt" . "ZQ=="), "_37c16e38832660230" . "6bacde35d5eba09" => base64_decode("aXNQYWdlc" . "w=="), "u" . "r" . "l" => base64_decode("dXJ" . "s"), "_16fbf5e7b21e27e" . "ecbd462ac8622e36" . "8" => base64_decode("cGFnZXMubWVudS5ub192aWV3X3" . "JpZ2h0cw=="), "_0c5123aa744f69bbc0e8b3ea2f" . "6e847d" => base64_decode("bG1zZ" . "w=="));
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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_0c5123aa744f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_16fbf5e7b21e27eecbd462ac" . "8622e368"]));
        }
        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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["ur" . "l"] => $url->GetUrl(), $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["nam" . "e"] => $_221da17e3055fae8d3ff516b832a5f3b->GetTitle(), $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_37c16e3883266" . "02306bacde35d5" . "eba09"] => 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["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_dc7c5c82cc9" . "76ae7af1dd13" . "efd610c37"]($_028c56e9753e5e2b616127818a6b7f8d, [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["u" . "r" . "l"] => $url->GetUrl(), $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["na" . "me"] => $_221da17e3055fae8d3ff516b832a5f3b->GetTitle()]);
            }
        }
        return $_028c56e9753e5e2b616127818a6b7f8d;
    }
}