Skip to content
Snippets Groups Projects
Commit 90ab140f authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Implementing signal slot for sitemap generation

parent a7d0f1ab
No related branches found
Tags 1.6.3
1 merge request!9Feature entry registration
......@@ -26,21 +26,76 @@ 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\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
/**
* Signal functions regarding sg_seo sitemap generation
*/
class SitemapSignalSlot {
const PLUGIN_NAME = 'sgjobs_jobapplication';
/**
* @var UriBuilder
*/
protected $uriBuilder;
/**
* before the sitemap is generated
*
* @param array $pageList
*/
public function beforeSitemapGeneration(array &$pageList) {
/** @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'
);
foreach ($rows as $row) {
$jobs = $this->getJobsByPid($row['pages']);
$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'));
$this->uriBuilder = $objectManager->get(UriBuilder::class);
foreach ($jobs as $job) {
$url = $this->uriBuilder->reset()->setTargetPageUid($row['pid'])->setArguments(
['tx_sgjobs_jobapplication' => ['jobId' => $job['uid']]]
)->buildFrontendUri();
$pageList[] = [
'url' => $url,
'title' => ''
];
}
}
}
/**
* get all jobs stored on specific page ids
*
* @param string $pid
* @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 . ')'
);
// @todo
# find sites where job detail plugin is added
# add entry for each job as parameter pid=x jobuid = y to pagelist
return $rows;
}
}
......@@ -66,8 +66,8 @@ $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class
);
$signalSlotDispatcher->connect(
\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class,
'beforeSitemapGeneration',
SGalinski\SgSeo\Generator\PagesSitemapGenerator::class,
'accessPageList'
\SGalinski\SgSeo\Generator\PagesSitemapGenerator::class,
'accessPageList',
\SGalinski\SgJobs\SignalSlot\SitemapSignalSlot::class,
'beforeSitemapGeneration'
);
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