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

[BUGFIX] Fix the complete broken code

parent 5c3596e1
No related branches found
Tags 1.6.3
1 merge request!9Feature entry registration
......@@ -26,21 +26,17 @@ namespace SGalinski\SgJobs\SignalSlot;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Database\DatabaseConnection;
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;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Page\PageGenerator;
use TYPO3\CMS\Frontend\Utility\EidUtility;
/**
* Signal functions regarding sg_seo sitemap generation
*/
class SitemapSignalSlot {
const PLUGIN_NAME = 'sgjobs_jobapplication';
/**
......@@ -49,7 +45,7 @@ class SitemapSignalSlot {
protected $uriBuilder;
/**
* before the sitemap is generated
* Before the sitemap is generated
*
* @param array $pageList
* @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
......@@ -60,28 +56,27 @@ class SitemapSignalSlot {
$request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
$request->setBaseUri(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
/** @var ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var ContentObjectRenderer $contentObjectRenderer */
$contentObjectRenderer = $objectManager->get(ContentObjectRenderer::class);
/** @var ConfigurationManager $configurationManager */
$configurationManager = $objectManager->get(ConfigurationManager::class);
$configurationManager->setContentObject($contentObjectRenderer);
$this->uriBuilder = $objectManager->get(UriBuilder::class);
$this->uriBuilder->injectConfigurationManager($configurationManager);
$this->initTSFE();
/** @var $databaseConnection DatabaseConnection */
$databaseConnection = $GLOBALS['TYPO3_DB'];
// find sites where job detail plugin is added
$rows = $databaseConnection->exec_SELECTgetRows(
'pid, pages',
'tt_content',
'CType = "list" and list_type = "' . self::PLUGIN_NAME . '" and hidden = 0 and deleted = 0'
);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$databaseResource = $queryBuilder->select('pid', 'pages')
->from('tt_content')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('list')),
$queryBuilder->expr()->eq('list_type', $queryBuilder->createNamedParameter(self::PLUGIN_NAME))
)
)
->execute();
$rows = $databaseResource->fetchAll();
foreach ($rows as $row) {
$jobs = $this->getJobsByPid($row['pages']);
......@@ -100,45 +95,18 @@ class SitemapSignalSlot {
}
/**
* Initializes TSFE and sets $GLOBALS['TSFE']
* Get all jobs stored on specific page ids
*
* @return void
* @throws \RuntimeException
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
*/
private function initTSFE() {
$GLOBALS['TSFE'] = $tsfe = GeneralUtility::makeInstance(
TypoScriptFrontendController::class, $GLOBALS['TYPO3_CONF_VARS'], GeneralUtility::_GP('id'), ''
);
/** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfe */
$tsfe->connectToDB();
$tsfe->initFEuser();
EidUtility::initTCA();
$tsfe->determineId();
$tsfe->initTemplate();
$tsfe->getConfigArray();
$tsfe->settingLanguage();
// Get linkVars, absRefPrefix, etc
PageGenerator::pagegenInit();
}
/**
* get all jobs stored on specific page ids
*
* @param string $pid
* @param string $pageList
* @return array|null
*/
private function getJobsByPid($pid) {
/** @var $databaseConnection DatabaseConnection */
$databaseConnection = $GLOBALS['TYPO3_DB'];
$rows = $databaseConnection->exec_SELECTgetRows(
'*',
'tx_sgjobs_domain_model_job',
'pid IN (' . $pid . ')'
);
return $rows;
private function getJobsByPid($pageList) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$databaseResource = $queryBuilder->select('*')
->from('tx_sgjobs_domain_model_job')
->where($queryBuilder->expr()->in('pid', $queryBuilder->createNamedParameter($pageList)))
->execute();
return $databaseResource->fetchAll();
}
}
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