HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/ijzerenman.komma.pro/app/Custom/Pages/Current.php
<?php


namespace Komma\Pages;


class Current
{
    protected $currentPageEntity;

    protected $currentParents;

    protected $meta;

    /**
     * @var
     */
    private $pageRepository;
    /**
     * @var MetaDataService
     */
    private $metaDataService;

    /**
     * @param PageRepository $pageRepository
     * @param MetaDataService $metaDataService
     */
    public function __construct(
        PageRepository $pageRepository,
        MetaDataService $metaDataService)
    {
        $this->pageRepository = $pageRepository;
        $this->metaDataService = $metaDataService;
    }

    public function set($data)
    {
        // Set entity
        $this->currentPageEntity = new PageEntity($data->routable->toArray());
        $this->currentPageEntity->route = $data->route;

        // Set parents
        $page = $data->routable->page;
        $this->currentParents = $this->pageRepository->getParents($page->lft, $page->rgt);

        // Set meta data
        $meta['title'] = $this->metaDataService->title($this->currentPageEntity, $this->currentParents);
        $meta['description'] = $this->metaDataService->description($this->currentPageEntity);
        $this->meta = (object) $meta;
    }

    public function setDefault()
    {
        $meta['title'] = '';
        $meta['description'] = '';
        $this->meta = (object) $meta;
    }

    public function pageEntity()
    {
        return $this->currentPageEntity;
    }

    public function parents()
    {
        return $this->currentParents;
    }

    public function meta()
    {
        return $this->meta;
    }
}