Skip to content
Snippets Groups Projects
Commit 13da19a5 authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] Fix and extremly simplify the sitemap link generation

parent 94169d0a
No related branches found
No related tags found
No related merge requests found
......@@ -28,10 +28,6 @@ namespace SGalinski\SgJobs\SignalSlot;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* Signal functions regarding sg_seo sitemap generation
......@@ -39,11 +35,6 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
class SitemapSignalSlot {
const PLUGIN_NAME = 'sgjobs_jobapplication';
/**
* @var UriBuilder
*/
protected $uriBuilder;
/**
* Before the sitemap is generated
*
......@@ -51,22 +42,9 @@ class SitemapSignalSlot {
* @param int $sysLanguageUid
*/
public function beforeSitemapGeneration(array &$pageList, int $sysLanguageUid) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$request = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
$request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
$request->setBaseUri(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$contentObjectRenderer = $objectManager->get(ContentObjectRenderer::class);
$configurationManager = $objectManager->get(ConfigurationManager::class);
$configurationManager->setContentObject($contentObjectRenderer);
$this->uriBuilder = $objectManager->get(UriBuilder::class);
$this->uriBuilder->injectConfigurationManager($configurationManager);
// find sites where job detail plugin is added
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
->getQueryBuilderForTable('tt_content');
$databaseResource = $queryBuilder->select('pid', 'pages')
->from('tt_content')
->where(
......@@ -88,17 +66,23 @@ class SitemapSignalSlot {
->execute();
$rows = $databaseResource->fetchAll();
foreach ($rows as $row) {
$jobs = $this->getJobsByPid($row['pages'], $sysLanguageUid);
foreach ($jobs as $job) {
$url = $this->uriBuilder->reset()->setTargetPageUid($row['pid'])->setArguments(
['tx_sgjobs_jobapplication' => ['jobId' => $job['uid']]]
)->setCreateAbsoluteUri(TRUE)->buildFrontendUri();
$url = $GLOBALS['TSFE']->cObj->typoLink_URL(
[
'parameter' => $row['pid'],
'linkAccessRestrictedPages' => 1,
'forceAbsoluteUrl' => 1,
'additionalParams' => GeneralUtility::implodeArrayForUrl(
NULL, ['tx_sgjobs_jobapplication[jobId]' => $job['uid']]
),
]
);
$pageList[] = [
'url' => $url,
'url' => htmlspecialchars($url),
'title' => ''
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment