From efac5c45a7c24da8d0ffb495b46507bffc083fdb Mon Sep 17 00:00:00 2001
From: Stefan Galinski <stefan@sgalinski.de>
Date: Wed, 20 Jul 2016 18:21:42 +0200
Subject: [PATCH] [FEATURE] Add realurl auto configuration

---
 Classes/Hooks/RealUrlAutoConfiguration.php | 62 ++++++++++++++++++++++
 ext_localconf.php                          |  6 ++-
 2 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 Classes/Hooks/RealUrlAutoConfiguration.php

diff --git a/Classes/Hooks/RealUrlAutoConfiguration.php b/Classes/Hooks/RealUrlAutoConfiguration.php
new file mode 100644
index 0000000..84c6f7e
--- /dev/null
+++ b/Classes/Hooks/RealUrlAutoConfiguration.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace SGalinski\SgNews\Hooks;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) sgalinski Internet Services (https://www.sgalinski.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 2 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.
+ *
+ *  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!
+ ***************************************************************/
+
+/**
+ * AutoConfiguration-Hook for RealURL
+ */
+class RealUrlAutoConfiguration {
+	/**
+	 * Generates additional RealURL configuration and merges it with provided configuration
+	 *
+	 * @param array $params Default configuration
+	 * @return array Updated configuration
+	 */
+	public function addNewsConfig($params) {
+		return array_merge_recursive(
+			$params['config'], [
+				'postVarSets' => [
+					'_DEFAULT' => [
+						'page' => [
+							[
+								'GETvar' => 'tx_sgnews_pagebrowser[currentPage]',
+							],
+						],
+					]
+				],
+				'fileName' => [
+					'index' => [
+						'news.xml' => [
+							'keyValues' => [
+								'type' => 78906523,
+							],
+						],
+					],
+				],
+			]
+		);
+	}
+}
diff --git a/ext_localconf.php b/ext_localconf.php
index 5ba6ec1..4b4bdb1 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -71,4 +71,8 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['proc
 $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Core\Page\PageRenderer'] =
 	['className' => 'SGalinski\SgNews\Xclass\PageRenderer'];
 
-?>
+// add realurl configuration
+if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
+	$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['sgnews'] =
+		\SGalinski\SgNews\Hooks\RealUrlAutoConfiguration::class . '->addNewsConfig';
+}
-- 
GitLab