<?php
namespace Meramo\Mrmbepages\Controller;

use Meramo\Mrmbepages\Controller\AbstractBackendController;
use Meramo\Mrmbepages\Domain\Repository\ActivepageRepository;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;


class ActivepageController extends AbstractBackendController
{
    
    /**
     * @var Meramo\Mrmbepages\Domain\Repository\ActivepageRepository $activepageRepository
     */
    protected $activepageRepository;

    /**
     * @param ActivepageRepository $activepageRepository
     */
    public function injectActivepageRepository(ActivepageRepository $activepageRepository): void
    {
        $this->activepageRepository = $activepageRepository;
    }

    protected function initializeView(ViewInterface $view)
    {
        if($view instanceof BackendTemplateView) {
            /** @var BackendTemplateView  $view*/
            parent::initializeView($view);
            $this->generateMenu();
        }
    }

    public function initializeAction()
    {
        $querySettings = $this->objectManager->get(Typo3QuerySettings::class);
        $querySettings->setRespectStoragePage(false);
        $this->activepageRepository->setDefaultQuerySettings($querySettings);
    }
    
}
