meilisearch/Classes/Domain/Index/PageIndexer/Helper/UriStrategyFactory.php

62 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2021-04-17 00:26:33 +02:00
<?php declare(strict_types = 1);
namespace WapplerSystems\Meilisearch\Domain\Index\PageIndexer\Helper;
/***************************************************************
* Copyright notice
*
* (c) 2019 Timo Hund <timo.hund@dkd.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use WapplerSystems\Meilisearch\Domain\Index\PageIndexer\Helper\UriBuilder\AbstractUriStrategy;
use WapplerSystems\Meilisearch\Domain\Index\PageIndexer\Helper\UriBuilder\TYPO3SiteStrategy;
use WapplerSystems\Meilisearch\System\Util\SiteUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* This class is responsible to retrieve an "UriStrategy" the can build uri's for the site where the
* passed page belongs to.
*
* This can be:
* * A TYPO3 site managed with site management
* * A TYPO3 site without site management where the url is build by EXT:meilisearch with L and id param and information from the domain
2021-04-17 21:20:54 +02:00
* record or meilisearch specific configuration.
2021-04-17 00:26:33 +02:00
*/
class UriStrategyFactory
{
/**
* @param integer $pageId
* @oaram array $overrideConfiguration
* @return AbstractUriStrategy
* @throws \Exception
*/
public function getForPageId(int $pageId): AbstractUriStrategy
{
if (!SiteUtility::getIsSiteManagedSite($pageId)) {
throw new \Exception('Site of page with uid ' . $pageId . ' is not a TYPO3 managed site');
}
return GeneralUtility::makeInstance(TYPO3SiteStrategy::class);
}
}