From 217d6289e05c0eeb9fe0e3bbad2a5ee91c38bc71 Mon Sep 17 00:00:00 2001 From: anjeylink Date: Mon, 13 Aug 2018 17:28:41 +0300 Subject: [PATCH] [TASK] remove usage of deprecated classes and functions. Log error if not possible to write to realurl config, instead of throwing exception --- Classes/DataProcessing/FlexFormProcessor.php | 3 +- .../FixedPostVarsConfigurationUtility.php | 51 ++++++++----------- Classes/Utility/HelperUtility.php | 9 ++-- .../ViewHelpers/ContentEditableViewHelper.php | 2 +- Classes/ViewHelpers/Link/TelViewHelper.php | 4 +- Classes/ViewHelpers/RegisterViewHelper.php | 5 +- Classes/ViewHelpers/Render/SvgViewHelper.php | 4 +- 7 files changed, 34 insertions(+), 44 deletions(-) diff --git a/Classes/DataProcessing/FlexFormProcessor.php b/Classes/DataProcessing/FlexFormProcessor.php index 04762646..0f54b99c 100644 --- a/Classes/DataProcessing/FlexFormProcessor.php +++ b/Classes/DataProcessing/FlexFormProcessor.php @@ -14,6 +14,7 @@ * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Service\FlexFormService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; @@ -56,7 +57,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu $fieldName = $cObj->stdWrapValue('fieldName', $processorConfiguration, 'pi_flexform'); // parse flexform - $flexformService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\FlexFormService'); + $flexformService = GeneralUtility::makeInstance(FlexFormService::class); $processedData[$targetVariableName] = $flexformService->convertFlexFormContentToArray($cObj->data[$fieldName]); // if targetvariable is settings, try to merge it with contentObjectConfiguration['settings.'] diff --git a/Classes/Utility/FixedPostVarsConfigurationUtility.php b/Classes/Utility/FixedPostVarsConfigurationUtility.php index 527ebb5d..92289499 100644 --- a/Classes/Utility/FixedPostVarsConfigurationUtility.php +++ b/Classes/Utility/FixedPostVarsConfigurationUtility.php @@ -3,6 +3,7 @@ namespace T3kit\themeT3kit\Utility; use Doctrine\DBAL\Query\QueryBuilder; +use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\DatabaseConnection; @@ -16,6 +17,7 @@ */ class FixedPostVarsConfigurationUtility { + use LoggerAwareTrait; /** * Update configuration file of fixed post vars @@ -27,9 +29,8 @@ public function updateConfiguration() $filePath = $this->getSaveFilePath(); if (!$this->canWriteConfiguration($filePath)) { - throw new \RuntimeException( - $filePath . ' is not writable.', - 1485349703 + $this->logger->error( + 'Could not write realurl configuration to file "' . $filePath . '"' ); } @@ -146,35 +147,23 @@ protected function getFixedPagesUids() { $field = 'tx_themet3kit_fixed_post_var_conf'; - if (version_compare(TYPO3_version, '8.0', '<')) { - /** @var DatabaseConnection $dbConnection */ - $dbConnection = $GLOBALS['TYPO3_DB']; - - $pages = $dbConnection->exec_SELECTgetRows( - 'uid, ' . $field, - 'pages', - $field . ' != \'0\' AND ' . $field . ' != \'\'' - . BackendUtility::deleteClause('pages') - ); - } else { - /** @var QueryBuilder $queryBuilder */ - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); - $pages = $queryBuilder - ->select('uid', 'tx_themet3kit_fixed_post_var_conf') - ->from('pages') - ->where( - $queryBuilder->expr()->neq( - $field, - $queryBuilder->createNamedParameter('') - ), - $queryBuilder->expr()->neq( - $field, - $queryBuilder->createNamedParameter('0') - ) + /** @var QueryBuilder $queryBuilder */ + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); + $pages = $queryBuilder + ->select('uid', 'tx_themet3kit_fixed_post_var_conf') + ->from('pages') + ->where( + $queryBuilder->expr()->neq( + $field, + $queryBuilder->createNamedParameter('') + ), + $queryBuilder->expr()->neq( + $field, + $queryBuilder->createNamedParameter('0') ) - ->execute() - ->fetchAll(); - } + ) + ->execute() + ->fetchAll(); return $pages; } diff --git a/Classes/Utility/HelperUtility.php b/Classes/Utility/HelperUtility.php index 4da960b5..923ec7b5 100644 --- a/Classes/Utility/HelperUtility.php +++ b/Classes/Utility/HelperUtility.php @@ -3,10 +3,11 @@ namespace T3kit\themeT3kit\Utility; +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageQueue; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Lang\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageService; /** * Class MainUtility @@ -29,11 +30,7 @@ class HelperUtility public static function getExtConf() { if (self::$extConf === null) { - if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['theme_t3kit'])) { - self::$extConf = unserialize((string)$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['theme_t3kit']); - } else { - self::$extConf = []; - } + self::$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('theme_t3kit') ?: []; } return self::$extConf; diff --git a/Classes/ViewHelpers/ContentEditableViewHelper.php b/Classes/ViewHelpers/ContentEditableViewHelper.php index 15f82c1d..712a919b 100644 --- a/Classes/ViewHelpers/ContentEditableViewHelper.php +++ b/Classes/ViewHelpers/ContentEditableViewHelper.php @@ -14,7 +14,7 @@ * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; diff --git a/Classes/ViewHelpers/Link/TelViewHelper.php b/Classes/ViewHelpers/Link/TelViewHelper.php index 46280d53..9b7eec24 100644 --- a/Classes/ViewHelpers/Link/TelViewHelper.php +++ b/Classes/ViewHelpers/Link/TelViewHelper.php @@ -14,6 +14,8 @@ * The TYPO3 project - inspiring people to share! */ +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; + /** * Tel link view helper. * Generates an tel link @@ -28,7 +30,7 @@ * +46 (0) 40-01 ma 23 45 67 * */ -class TelViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper +class TelViewHelper extends AbstractTagBasedViewHelper { /** * @var string diff --git a/Classes/ViewHelpers/RegisterViewHelper.php b/Classes/ViewHelpers/RegisterViewHelper.php index 749ae501..30375859 100644 --- a/Classes/ViewHelpers/RegisterViewHelper.php +++ b/Classes/ViewHelpers/RegisterViewHelper.php @@ -14,8 +14,7 @@ * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; @@ -26,7 +25,7 @@ * @subpackage * @author Markus Goldbach */ -class RegisterViewHelper extends AbstractViewHelper implements CompilableInterface +class RegisterViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; diff --git a/Classes/ViewHelpers/Render/SvgViewHelper.php b/Classes/ViewHelpers/Render/SvgViewHelper.php index 1acd4ab0..12795e5d 100644 --- a/Classes/ViewHelpers/Render/SvgViewHelper.php +++ b/Classes/ViewHelpers/Render/SvgViewHelper.php @@ -1,6 +1,8 @@