1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Index\PageIndexer\Helper\UriBuilder; |
4
|
|
|
|
5
|
|
|
/*************************************************************** |
6
|
|
|
* Copyright notice |
7
|
|
|
* |
8
|
|
|
* (c) 2019 Timo Hund <[email protected]> |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* A copy is found in the textfile GPL.txt and important notices to the license |
20
|
|
|
* from the author is found in LICENSE.txt distributed with these scripts. |
21
|
|
|
* |
22
|
|
|
* |
23
|
|
|
* This script is distributed in the hope that it will be useful, |
24
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
25
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26
|
|
|
* GNU General Public License for more details. |
27
|
|
|
* |
28
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
29
|
|
|
***************************************************************/ |
30
|
|
|
|
31
|
|
|
use ApacheSolrForTypo3\Solr\IndexQueue\Item; |
32
|
|
|
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; |
33
|
|
|
use TYPO3\CMS\Core\Site\SiteFinder; |
34
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* This class is used to build the indexing url for a TYPO3 site that is managed with the TYPO3 site management. |
38
|
|
|
* |
39
|
|
|
* These sites have the pageId and language information encoded in the speaking url. |
40
|
|
|
* |
41
|
|
|
* @package ApacheSolrForTypo3\Solr\Domain\Index\PageIndexer\Helper\UriBuilder |
42
|
|
|
*/ |
43
|
|
|
class TYPO3SiteStrategy extends AbstractUriStrategy |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* @var SiteFinder |
47
|
|
|
*/ |
48
|
|
|
protected $siteFinder = null; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* TYPO3SiteStrategy constructor. |
52
|
|
|
* @param SolrLogManager|null $logger |
53
|
|
|
* @param SiteFinder|null $siteFinder |
54
|
|
|
*/ |
55
|
|
|
public function __construct(SolrLogManager $logger = null, SiteFinder $siteFinder = null) |
56
|
|
|
{ |
57
|
|
|
parent::__construct($logger); |
58
|
|
|
$this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param Item $item |
63
|
|
|
* @param int $language |
64
|
|
|
* @param string $mountPointParameter |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
protected function buildPageIndexingUriFromPageItemAndLanguageId(Item $item, int $language = 0, string $mountPointParameter = '') |
68
|
|
|
{ |
69
|
|
|
$site = $this->siteFinder->getSiteByPageId($item->getRecordUid()); |
70
|
|
|
$parameters = []; |
71
|
|
|
|
72
|
|
|
if ($language > 0) { |
73
|
|
|
$parameters['_language'] = $language; |
74
|
|
|
}; |
75
|
|
|
|
76
|
|
|
if ($mountPointParameter !== '') { |
77
|
|
|
$parameters['MP'] = $mountPointParameter; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$pageIndexUri = (string)$site->getRouter()->generateUri($item->getRecord(), $parameters); |
81
|
|
|
return $pageIndexUri; |
82
|
|
|
} |
83
|
|
|
} |