Commit afd24c98 authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[BUGFIX] Fix heavy performance issue with the typoscript parsing

parent 2f78be32
......@@ -5,7 +5,7 @@ namespace SGalinski\SgContentlink\TCA;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
* (c) sgalinski Internet Services (https://www.sgalinski.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......@@ -102,5 +102,3 @@ class TcaProvider implements SingletonInterface{
unset(self::$allowedTypesForContentLink[$allowedTypeForContentLink]);
}
}
?>
......@@ -5,7 +5,7 @@ namespace SGalinski\SgContentlink\UserFunc;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
......@@ -26,9 +26,6 @@ namespace SGalinski\SgContentlink\UserFunc;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager;
use TYPO3\CMS\Extbase\Service\TypoScriptService;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
......@@ -40,42 +37,6 @@ class ContentElementRendering {
*/
public $cObj;
/**
* @var array
*/
protected $overwrites = array();
/**
* @var array
*/
protected $additions = array();
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
*/
protected $objectManager;
public function __construct() {
$this->objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
/** @var TypoScriptService $typoScriptService */
$class = 'TYPO3\CMS\Extbase\Service\TypoScriptService';
$typoScriptService = $this->objectManager->get($class);
/** @var BackendConfigurationManager $configurationManager */
$class = 'TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager';
$configurationManager = $this->objectManager->get($class);
$settings = $typoScriptService->convertTypoScriptArrayToPlainArray($configurationManager->getTypoScriptSetup());
if (version_compare(TYPO3_branch, '7.6', '<')) {
$this->overwrites = $settings['plugin.']['tx_sgcontentlink.']['settings.']['link.']['overwrite.'];
$this->additions = $settings['plugin.']['tx_sgcontentlink.']['settings.']['link.']['add.'];
} else {
$this->overwrites = $settings['plugin']['tx_sgcontentlink']['settings']['link']['overwrite'];
$this->additions = $settings['plugin']['tx_sgcontentlink']['settings']['link']['add'];
}
}
/**
* Adds parameters to the current content element.
*
......@@ -95,21 +56,24 @@ class ContentElementRendering {
}
/**
* Returns the parameters for the typo link.
* Returns the parameters for the typolink.
*
* @return array
*/
protected function getParameters() {
$overwrites = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sgcontentlink.']['settings.']['link.']['overwrite.'];
$additions = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sgcontentlink.']['settings.']['link.']['add.'];
$parameters = str_getcsv($this->cObj->data['tx_sgcontentlink_contentlink'], ' ', '"');
$defaultTarget = $this->overwrites['defaultTarget'];
$defaultTarget = $overwrites['defaultTarget'];
if ($defaultTarget) {
$parameters[1] = $defaultTarget;
} elseif (!isset($parameters[1])) {
$parameters[1] = '-';
}
$defaultClass = $this->overwrites['defaultClass'];
$addClass = $this->additions['class'];
$defaultClass = $overwrites['defaultClass'];
$addClass = $additions['class'];
$classIsSet = isset($parameters[2]);
if ($defaultClass) {
$parameters[2] = $defaultClass;
......@@ -121,8 +85,8 @@ class ContentElementRendering {
$parameters[2] = '-';
}
$defaultTitle = $this->overwrites['defaultTitle'];
$addTitle = $this->additions['title'];
$defaultTitle = $overwrites['defaultTitle'];
$addTitle = $additions['title'];
$titleIsSet = isset($parameters[3]);
if ($defaultTitle) {
$parameters[3] = $defaultTitle;
......
# Change page rendering with user function
# Change content rendering with user function
tt_content.stdWrap.postUserFunc = SGalinski\SgContentlink\UserFunc\ContentElementRendering->wrapContentLinkAroundContent
plugin.tx_sgcontentlink {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment