[TASK] Replace static MarkerUtility with object 82/42882/7
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 26 Aug 2015 11:16:49 +0000 (13:16 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 27 Aug 2015 22:42:42 +0000 (00:42 +0200)
The static MarkerUtility introduced by #69262 can easily replaced with
an object. This makes mocking for tests easier. Deprecation will be
easier as soon the marker support is dropped, too.

Change-Id: I14c2a8402888dfaaa48b0fb9e6c9b40475fd800d
Resolves: #69329
Relates: #69262
Releases: master
Reviewed-on: http://review.typo3.org/42882
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
16 files changed:
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Sprite/SpriteGenerator.php
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/core/Classes/Html/HtmlParser.php
typo3/sysext/core/Classes/Messaging/AbstractStandaloneMessage.php
typo3/sysext/core/Classes/Page/PageRenderer.php
typo3/sysext/core/Classes/Service/MarkerBasedTemplateService.php [new file with mode: 0644]
typo3/sysext/core/Classes/Utility/MarkerUtility.php [deleted file]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-69262-MoveMarkerSubstitutionFunctionalityToOwnClass.rst
typo3/sysext/core/Tests/Unit/Service/MarkerBasedTemplateServiceTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Utility/MarkerUtilityTest.php [deleted file]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/linkvalidator/Classes/Report/LinkValidatorReport.php
typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php
typo3/sysext/version/Classes/Hook/DataHandlerHook.php

index edbf419..7b885a4 100644 (file)
@@ -30,7 +30,7 @@ use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
-use TYPO3\CMS\Core\Utility\MarkerUtility;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -1230,10 +1230,12 @@ class EditDocumentController implements \TYPO3\CMS\Core\Http\ControllerInterface
         * @return string The HTML
         */
        public function extraFormHeaders() {
+               /** @var MarkerBasedTemplateService $templateService */
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
                $extraTemplate = '';
                if (is_array($this->tceforms->extraFormHeaders)) {
-                       $extraTemplate = MarkerUtility::getSubpart($this->doc->moduleTemplate, '###DOCHEADER_EXTRAHEADER###');
-                       $extraTemplate = MarkerUtility::substituteMarker($extraTemplate, '###EXTRAHEADER###', implode(LF, $this->tceforms->extraFormHeaders));
+                       $extraTemplate = $templateService->getSubpart($this->doc->moduleTemplate, '###DOCHEADER_EXTRAHEADER###');
+                       $extraTemplate = $templateService->substituteMarker($extraTemplate, '###EXTRAHEADER###', implode(LF, $this->tceforms->extraFormHeaders));
                }
                return $extraTemplate;
        }
index baf625b..0613552 100644 (file)
@@ -24,10 +24,10 @@ use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\Html\HtmlParser;
 use TYPO3\CMS\Core\Http\AjaxRequestHandler;
 use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MarkerUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Lang\LanguageService;
 
@@ -233,8 +233,10 @@ class FormEngine {
                }
                $this->templateFile = 'sysext/backend/Resources/Private/Templates/FormEngine.html';
                $template = GeneralUtility::getUrl(PATH_typo3 . $this->templateFile);
+               /** @var MarkerBasedTemplateService $templateService */
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
                // Wrapping all table rows for a particular record being edited:
-               $this->totalWrap = MarkerUtility::getSubpart($template, '###TOTALWRAP###');
+               $this->totalWrap = $templateService->getSubpart($template, '###TOTALWRAP###');
                $this->nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
        }
 
index 125b731..9d05b31 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Backend\Sprite;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Utility\MarkerUtility;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -318,6 +318,8 @@ class SpriteGenerator {
         * @return void
         */
        protected function generateCSS() {
+               /** @var MarkerBasedTemplateService $templateService */
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
                $cssData = '';
                if ($this->includeTimestampInCSS) {
                        $timestamp = '?' . time();
@@ -335,7 +337,7 @@ class SpriteGenerator {
                $markerArray['###SPRITEURL###'] .= $this->spriteName . '.png' . $timestamp;
                foreach ($this->spriteBases as $base) {
                        $markerArray['###SPRITENAME###'] = $base;
-                       $cssData .= MarkerUtility::substituteMarkerArray($this->templateSprite, $markerArray);
+                       $cssData .= $templateService->substituteMarkerArray($this->templateSprite, $markerArray);
 
                        if ($this->enableHighDensitySprite) {
                                $highDensityMarkerArray = array_merge($markerArray, array(
@@ -347,7 +349,7 @@ class SpriteGenerator {
                                                $markerArray['###SPRITEURL###']
                                        )
                                ));
-                               $cssData .= MarkerUtility::substituteMarkerArray($this->templateSpriteHighDensity, $highDensityMarkerArray);
+                               $cssData .= $templateService->substituteMarkerArray($this->templateSpriteHighDensity, $highDensityMarkerArray);
                        }
                }
 
@@ -368,7 +370,7 @@ class SpriteGenerator {
                        if ($data['width'] != $this->defaultWidth) {
                                $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'width: ' . $data['width'] . 'px;' . LF;
                        }
-                       $cssData .= MarkerUtility::substituteMarkerArray($this->templateIcon, $markerArrayIcons);
+                       $cssData .= $templateService->substituteMarkerArray($this->templateIcon, $markerArrayIcons);
                }
                GeneralUtility::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '.css', $cssData);
        }
index e38cc66..7fdf20b 100644 (file)
@@ -17,10 +17,10 @@ namespace TYPO3\CMS\Backend\Template;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
-use TYPO3\CMS\Core\Utility\MarkerUtility;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
@@ -373,6 +373,11 @@ function jumpToUrl(URL) {
         */
        protected $iconFactory;
 
+       /**
+        * @var MarkerBasedTemplateService
+        */
+       protected $templateService;
+
        const STATUS_ICON_ERROR = 3;
        const STATUS_ICON_WARNING = 2;
        const STATUS_ICON_NOTIFICATION = 1;
@@ -389,6 +394,9 @@ function jumpToUrl(URL) {
                $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LegacyCssClasses');
                $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
 
+               // initialize Marker Support
+               $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+
                // Setting default scriptID:
                if (($temp_M = (string)GeneralUtility::_GET('M')) && $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M]) {
                        $this->scriptID = preg_replace('/^.*\\/(sysext|ext)\\//', 'ext/', $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M] . 'index.php');
@@ -1692,7 +1700,7 @@ function jumpToUrl(URL) {
         */
        public function moduleBody($pageRecord = array(), $buttons = array(), $markerArray = array(), $subpartArray = array()) {
                // Get the HTML template for the module
-               $moduleBody = MarkerUtility::getSubpart($this->moduleTemplate, '###FULLDOC###');
+               $moduleBody = $this->templateService->getSubpart($this->moduleTemplate, '###FULLDOC###');
                // Add CSS
                $this->inDocStylesArray[] = 'html { overflow: hidden; }';
                // Get the page path for the docheader
@@ -1705,7 +1713,7 @@ function jumpToUrl(URL) {
                $markerArray = array_merge($markerArray, $docHeaderButtons);
                // replacing subparts
                foreach ($subpartArray as $marker => $content) {
-                       $moduleBody = MarkerUtility::substituteSubpart($moduleBody, $marker, $content);
+                       $moduleBody = $this->templateService->substituteSubpart($moduleBody, $marker, $content);
                }
                // adding flash messages
                if ($this->showFlashMessages) {
@@ -1733,7 +1741,7 @@ function jumpToUrl(URL) {
                        }
                }
                // Replacing all markers with the finished markers and return the HTML content
-               return MarkerUtility::substituteMarkerArray($moduleBody, $markerArray, '###|###');
+               return $this->templateService->substituteMarkerArray($moduleBody, $markerArray, '###|###');
        }
 
        /**
@@ -1773,20 +1781,20 @@ function jumpToUrl(URL) {
                $floats = array('left', 'right');
                foreach ($floats as $key) {
                        // Get the template for each float
-                       $buttonTemplate = MarkerUtility::getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
+                       $buttonTemplate = $this->templateService->getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
                        // Fill the button markers in this float
-                       $buttonTemplate = MarkerUtility::substituteMarkerArray($buttonTemplate, $buttons, '###|###', TRUE);
+                       $buttonTemplate = $this->templateService->substituteMarkerArray($buttonTemplate, $buttons, '###|###', TRUE);
                        // getting the wrap for each group
-                       $buttonWrap = MarkerUtility::getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
+                       $buttonWrap = $this->templateService->getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
                        // looping through the groups (max 6) and remove the empty groups
                        for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) {
                                $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
-                               $buttonGroup = MarkerUtility::getSubpart($buttonTemplate, $buttonMarker);
+                               $buttonGroup = $this->templateService->getSubpart($buttonTemplate, $buttonMarker);
                                if (trim($buttonGroup)) {
                                        if ($buttonWrap) {
-                                               $buttonGroup = MarkerUtility::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
+                                               $buttonGroup = $this->templateService->substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
                                        }
-                                       $buttonTemplate = MarkerUtility::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
+                                       $buttonTemplate = $this->templateService->substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
                                }
                        }
                        // Replace the marker with the template and remove all line breaks (for IE compat)
index 092051a..94b588a 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Core\Html;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MarkerUtility;
 
 
 /**
@@ -40,11 +40,12 @@ class HtmlParser {
         * @param string $marker Marker string, eg. "###CONTENT_PART###
         *
         * @return string
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerUtility accordingly
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly
         */
        static public function getSubpart($content, $marker) {
                GeneralUtility::logDeprecatedFunction();
-               return MarkerUtility::getSubpart($content, $marker);
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return $templateService->getSubpart($content, $marker);
        }
 
        /**
@@ -57,11 +58,12 @@ class HtmlParser {
         * @param bool $keepMarker If set, the marker around the subpart is not removed, but kept in the output
         *
         * @return string Processed input content
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerUtility accordingly
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly
         */
        static public function substituteSubpart($content, $marker, $subpartContent, $recursive = TRUE, $keepMarker = FALSE) {
                GeneralUtility::logDeprecatedFunction();
-               return MarkerUtility::substituteSubpart($content, $marker, $subpartContent, $recursive, $keepMarker);
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return $templateService->substituteSubpart($content, $marker, $subpartContent, $recursive, $keepMarker);
        }
 
        /**
@@ -71,11 +73,12 @@ class HtmlParser {
         * @param array $subpartsContent The array of key/value pairs being subpart/content values used in the substitution. For each element in this array the function will substitute a subpart in the content stream with the content.
         *
         * @return string The processed HTML content string.
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerUtility accordingly
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly
         */
        static public function substituteSubpartArray($content, array $subpartsContent) {
                GeneralUtility::logDeprecatedFunction();
-               return MarkerUtility::substituteSubpartArray($content, $subpartsContent);
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return $templateService->substituteSubpartArray($content, $subpartsContent);
        }
 
        /**
@@ -87,11 +90,12 @@ class HtmlParser {
         * @param mixed $markContent The content to insert instead of the marker string found.
         *
         * @return string The processed HTML content string.
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerUtility accordingly
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly
         */
        static public function substituteMarker($content, $marker, $markContent) {
                GeneralUtility::logDeprecatedFunction();
-               return MarkerUtility::substituteMarker($content, $marker, $markContent);
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return $templateService->substituteMarker($content, $marker, $markContent);
        }
 
        /**
@@ -111,11 +115,12 @@ class HtmlParser {
         * @param bool $deleteUnused If set, all unused marker are deleted.
         *
         * @return string The processed output stream
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerUtility accordingly
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly
         */
        static public function substituteMarkerArray($content, $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
                GeneralUtility::logDeprecatedFunction();
-               return MarkerUtility::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return $templateService->substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
        }
 
        /**
@@ -154,11 +159,12 @@ class HtmlParser {
         * @param bool $deleteUnused If set, all unused single markers are deleted.
         *
         * @return string The processed output stream
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerUtility accordingly
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly
         */
        static public function substituteMarkerAndSubpartArrayRecursive($content, array $markersAndSubparts, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
                GeneralUtility::logDeprecatedFunction();
-               return MarkerUtility::substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return $templateService->substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
        }
 
        /************************************
index 5f02c15..e4ad5b4 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 namespace TYPO3\CMS\Core\Messaging;
 
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /*
  * This file is part of the TYPO3 CMS project.
  *
@@ -86,7 +89,7 @@ abstract class AbstractStandaloneMessage extends AbstractMessage {
                        // Avoid calling TYPO3_SITE_URL here to get the base URL as it might be that we output an exception message with
                        // invalid trusted host, which would lead to a nested exception! See: #30377
                        // Instead we calculate the relative path to the document root without involving HTTP request parameters.
-                       '###BASEURL###' => substr(PATH_site, strlen(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'))),
+                       '###BASEURL###' => substr(PATH_site, strlen(GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'))),
                        '###TYPO3_mainDir###' => TYPO3_mainDir,
                        '###TYPO3_copyright_year###' => TYPO3_copyright_year
                );
@@ -125,8 +128,9 @@ abstract class AbstractStandaloneMessage extends AbstractMessage {
         */
        public function render() {
                $markers = array_merge($this->getDefaultMarkers(), $this->markers);
-               $content = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($this->htmlTemplate);
-               $content = \TYPO3\CMS\Core\Utility\MarkerUtility::substituteMarkerArray($content, $markers, '', FALSE, TRUE);
+               $content = GeneralUtility::getUrl($this->htmlTemplate);
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               $content = $templateService->substituteMarkerArray($content, $markers, '', FALSE, TRUE);
                return $content;
        }
 
index 65e8b38..a4f2df3 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Page;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -1726,7 +1727,8 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface {
                // This means that you can only register footer files *after* the header has been already rendered.
                // In case you render the footer part first, header files can only be added *after* the footer has been rendered
                $this->reset();
-               return trim(\TYPO3\CMS\Core\Utility\MarkerUtility::substituteMarkerArray($template, $markerArray, '###|###'));
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
        }
 
        /**
@@ -1740,7 +1742,8 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface {
                $this->prepareRendering();
                $markerArray = $this->getPreparedMarkerArrayForPageWithUncachedObjects($substituteHash);
                $template = $this->getTemplateForPart(self::PART_COMPLETE);
-               return trim(\TYPO3\CMS\Core\Utility\MarkerUtility::substituteMarkerArray($template, $markerArray, '###|###'));
+               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+               return trim($templateService->substituteMarkerArray($template, $markerArray, '###|###'));
        }
 
        /**
diff --git a/typo3/sysext/core/Classes/Service/MarkerBasedTemplateService.php b/typo3/sysext/core/Classes/Service/MarkerBasedTemplateService.php
new file mode 100644 (file)
index 0000000..26f6718
--- /dev/null
@@ -0,0 +1,306 @@
+<?php
+namespace TYPO3\CMS\Core\Service;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Helper functionality for subparts and marker substitution
+ * ###MYMARKER###
+ */
+class MarkerBasedTemplateService {
+
+       /**
+        * Returns the first subpart encapsulated in the marker, $marker
+        * (possibly present in $content as a HTML comment)
+        *
+        * @param string $content Content with subpart wrapped in fx. "###CONTENT_PART###" inside.
+        * @param string $marker Marker string, eg. "###CONTENT_PART###
+        *
+        * @return string
+        */
+       public function getSubpart($content, $marker) {
+               $start = strpos($content, $marker);
+               if ($start === FALSE) {
+                       return '';
+               }
+               $start += strlen($marker);
+               $stop = strpos($content, $marker, $start);
+               // Q: What shall get returned if no stop marker is given
+               // Everything till the end or nothing?
+               if ($stop === FALSE) {
+                       return '';
+               }
+               $content = substr($content, $start, $stop - $start);
+               $matches = array();
+               if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $content, $matches) === 1) {
+                       return $matches[2];
+               }
+               // Resetting $matches
+               $matches = array();
+               if (preg_match('/(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $content, $matches) === 1) {
+                       return $matches[1];
+               }
+               // Resetting $matches
+               $matches = array();
+               if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)$/s', $content, $matches) === 1) {
+                       return $matches[2];
+               }
+
+               return $content;
+       }
+
+       /**
+        * Substitutes a subpart in $content with the content of $subpartContent.
+        *
+        * @param string $content Content with subpart wrapped in fx. "###CONTENT_PART###" inside.
+        * @param string $marker Marker string, eg. "###CONTENT_PART###
+        * @param array $subpartContent If $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the content of the subpart (fetched by getSubpart())
+        * @param bool $recursive If $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted!
+        * @param bool $keepMarker If set, the marker around the subpart is not removed, but kept in the output
+        *
+        * @return string Processed input content
+        */
+       public function substituteSubpart($content, $marker, $subpartContent, $recursive = TRUE, $keepMarker = FALSE) {
+               $start = strpos($content, $marker);
+               if ($start === FALSE) {
+                       return $content;
+               }
+               $startAM = $start + strlen($marker);
+               $stop = strpos($content, $marker, $startAM);
+               if ($stop === FALSE) {
+                       return $content;
+               }
+               $stopAM = $stop + strlen($marker);
+               $before = substr($content, 0, $start);
+               $after = substr($content, $stopAM);
+               $between = substr($content, $startAM, $stop - $startAM);
+               if ($recursive) {
+                       $after = $this->substituteSubpart($after, $marker, $subpartContent, $recursive, $keepMarker);
+               }
+               if ($keepMarker) {
+                       $matches = array();
+                       if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
+                               $before .= $marker . $matches[1];
+                               $between = $matches[2];
+                               $after = $matches[3] . $marker . $after;
+                       } elseif (preg_match('/^(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
+                               $before .= $marker;
+                               $between = $matches[1];
+                               $after = $matches[2] . $marker . $after;
+                       } elseif (preg_match('/^([^\\<]*\\-\\-\\>)(.*)$/s', $between, $matches) === 1) {
+                               $before .= $marker . $matches[1];
+                               $between = $matches[2];
+                               $after = $marker . $after;
+                       } else {
+                               $before .= $marker;
+                               $after = $marker . $after;
+                       }
+               } else {
+                       $matches = array();
+                       if (preg_match('/^(.*)\\<\\!\\-\\-[^\\>]*$/s', $before, $matches) === 1) {
+                               $before = $matches[1];
+                       }
+                       if (is_array($subpartContent)) {
+                               $matches = array();
+                               if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
+                                       $between = $matches[2];
+                               } elseif (preg_match('/^(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
+                                       $between = $matches[1];
+                               } elseif (preg_match('/^([^\\<]*\\-\\-\\>)(.*)$/s', $between, $matches) === 1) {
+                                       $between = $matches[2];
+                               }
+                       }
+                       $matches = array();
+                       // resetting $matches
+                       if (preg_match('/^[^\\<]*\\-\\-\\>(.*)$/s', $after, $matches) === 1) {
+                               $after = $matches[1];
+                       }
+               }
+               if (is_array($subpartContent)) {
+                       $between = $subpartContent[0] . $between . $subpartContent[1];
+               } else {
+                       $between = $subpartContent;
+               }
+
+               return $before . $between . $after;
+       }
+
+       /**
+        * Substitues multiple subparts at once
+        *
+        * @param string $content The content stream, typically HTML template content.
+        * @param array $subpartsContent The array of key/value pairs being subpart/content values used in the substitution. For each element in this array the function will substitute a subpart in the content stream with the content.
+        *
+        * @return string The processed HTML content string.
+        */
+       public function substituteSubpartArray($content, array $subpartsContent) {
+               foreach ($subpartsContent as $subpartMarker => $subpartContent) {
+                       $content = $this->substituteSubpart($content, $subpartMarker, $subpartContent);
+               }
+
+               return $content;
+       }
+
+       /**
+        * Substitutes a marker string in the input content
+        * (by a simple str_replace())
+        *
+        * @param string $content The content stream, typically HTML template content.
+        * @param string $marker The marker string, typically on the form "###[the marker string]###
+        * @param mixed $markContent The content to insert instead of the marker string found.
+        *
+        * @return string The processed HTML content string.
+        * @see substituteSubpart()
+        */
+       public function substituteMarker($content, $marker, $markContent) {
+               return str_replace($marker, $markContent, $content);
+       }
+
+       /**
+        * Traverses the input $markContentArray array and for each key the marker
+        * by the same name (possibly wrapped and in upper case) will be
+        * substituted with the keys value in the array. This is very useful if you
+        * have a data-record to substitute in some content. In particular when you
+        * use the $wrap and $uppercase values to pre-process the markers. Eg. a
+        * key name like "myfield" could effectively be represented by the marker
+        * "###MYFIELD###" if the wrap value was "###|###" and the $uppercase
+        * boolean TRUE.
+        *
+        * @param string $content The content stream, typically HTML template content.
+        * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
+        * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution
+        * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
+        * @param bool $deleteUnused If set, all unused marker are deleted.
+        *
+        * @return string The processed output stream
+        * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
+        */
+       public function substituteMarkerArray($content, $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
+               if (is_array($markContentArray)) {
+                       $wrapArr = GeneralUtility::trimExplode('|', $wrap);
+                       $search = array();
+                       $replace = array();
+                       foreach ($markContentArray as $marker => $markContent) {
+                               if ($uppercase) {
+                                       // use strtr instead of strtoupper to avoid locale problems with Turkish
+                                       $marker = strtr($marker, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
+                               }
+                               if (!empty($wrapArr)) {
+                                       $marker = $wrapArr[0] . $marker . $wrapArr[1];
+                               }
+                               $search[] = $marker;
+                               $replace[] = $markContent;
+                       }
+                       $content = str_replace($search, $replace, $content);
+                       unset($search, $replace);
+                       if ($deleteUnused) {
+                               if (empty($wrap)) {
+                                       $wrapArr = array('###', '###');
+                               }
+                               $content = preg_replace('/' . preg_quote($wrapArr[0], '/') . '([A-Z0-9_|\\-]*)' . preg_quote($wrapArr[1], '/') . '/is', '', $content);
+                       }
+               }
+
+               return $content;
+       }
+
+       /**
+        * Replaces all markers and subparts in a template with the content provided in the structured array.
+        *
+        * The array is built like the template with its markers and subparts. Keys represent the marker name and the values the
+        * content.
+        * If the value is not an array the key will be treated as a single marker.
+        * If the value is an array the key will be treated as a subpart marker.
+        * Repeated subpart contents are of course elements in the array, so every subpart value must contain an array with its
+        * markers.
+        *
+        * $markersAndSubparts = array (
+        *    '###SINGLEMARKER1###' => 'value 1',
+        *    '###SUBPARTMARKER1###' => array(
+        *        0 => array(
+        *            '###SINGLEMARKER2###' => 'value 2',
+        *        ),
+        *        1 => array(
+        *            '###SINGLEMARKER2###' => 'value 3',
+        *        )
+        *    ),
+        *    '###SUBPARTMARKER2###' => array(
+        *    ),
+        * )
+        * Subparts can be nested, so below the 'SINGLEMARKER2' it is possible to have another subpart marker with an array as the
+        * value, which in its turn contains the elements of the sub-subparts.
+        * Empty arrays for Subparts will cause the subtemplate to be cleared.
+        *
+        * @static
+        *
+        * @param string $content The content stream, typically HTML template content.
+        * @param array $markersAndSubparts The array of single markers and subpart contents.
+        * @param string $wrap A wrap value - [part1] | [part2] - for the markers before substitution.
+        * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
+        * @param bool $deleteUnused If set, all unused single markers are deleted.
+        *
+        * @return string The processed output stream
+        */
+       public function substituteMarkerAndSubpartArrayRecursive($content, array $markersAndSubparts, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
+               $wraps = GeneralUtility::trimExplode('|', $wrap);
+               $singleItems = array();
+               $compoundItems = array();
+               // Split markers and subparts into separate arrays
+               foreach ($markersAndSubparts as $markerName => $markerContent) {
+                       if (is_array($markerContent)) {
+                               $compoundItems[] = $markerName;
+                       } else {
+                               $singleItems[$markerName] = $markerContent;
+                       }
+               }
+               $subTemplates = array();
+               $subpartSubstitutes = array();
+               // Build a cache for the sub template
+               foreach ($compoundItems as $subpartMarker) {
+                       if ($uppercase) {
+                               // Use strtr instead of strtoupper to avoid locale problems with Turkish
+                               $subpartMarker = strtr($subpartMarker, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
+                       }
+                       if (!empty($wraps)) {
+                               $subpartMarker = $wraps[0] . $subpartMarker . $wraps[1];
+                       }
+                       $subTemplates[$subpartMarker] = $this->getSubpart($content, $subpartMarker);
+               }
+               // Replace the subpart contents recursively
+               foreach ($compoundItems as $subpartMarker) {
+                       $completeMarker = $subpartMarker;
+                       if ($uppercase) {
+                               // use strtr instead of strtoupper to avoid locale problems with Turkish
+                               $completeMarker = strtr($completeMarker, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
+                       }
+                       if (!empty($wraps)) {
+                               $completeMarker = $wraps[0] . $completeMarker . $wraps[1];
+                       }
+                       if (!empty($markersAndSubparts[$subpartMarker])) {
+                               foreach ($markersAndSubparts[$subpartMarker] as $partialMarkersAndSubparts) {
+                                       $subpartSubstitutes[$completeMarker] .= $this->substituteMarkerAndSubpartArrayRecursive($subTemplates[$completeMarker],
+                                               $partialMarkersAndSubparts, $wrap, $uppercase, $deleteUnused);
+                               }
+                       } else {
+                               $subpartSubstitutes[$completeMarker] = '';
+                       }
+               }
+               // Substitute the single markers and subparts
+               $result = $this->substituteSubpartArray($content, $subpartSubstitutes);
+               $result = $this->substituteMarkerArray($result, $singleItems, $wrap, $uppercase, $deleteUnused);
+
+               return $result;
+       }
+}
diff --git a/typo3/sysext/core/Classes/Utility/MarkerUtility.php b/typo3/sysext/core/Classes/Utility/MarkerUtility.php
deleted file mode 100644 (file)
index e3097f7..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Utility;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Helper functionality for subparts and marker substitution
- * ###MYMARKER###
- */
-class MarkerUtility {
-
-       /**
-        * Returns the first subpart encapsulated in the marker, $marker
-        * (possibly present in $content as a HTML comment)
-        *
-        * @param string $content Content with subpart wrapped in fx. "###CONTENT_PART###" inside.
-        * @param string $marker Marker string, eg. "###CONTENT_PART###
-        *
-        * @return string
-        */
-       static public function getSubpart($content, $marker) {
-               $start = strpos($content, $marker);
-               if ($start === FALSE) {
-                       return '';
-               }
-               $start += strlen($marker);
-               $stop = strpos($content, $marker, $start);
-               // Q: What shall get returned if no stop marker is given
-               // Everything till the end or nothing?
-               if ($stop === FALSE) {
-                       return '';
-               }
-               $content = substr($content, $start, $stop - $start);
-               $matches = array();
-               if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $content, $matches) === 1) {
-                       return $matches[2];
-               }
-               // Resetting $matches
-               $matches = array();
-               if (preg_match('/(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $content, $matches) === 1) {
-                       return $matches[1];
-               }
-               // Resetting $matches
-               $matches = array();
-               if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)$/s', $content, $matches) === 1) {
-                       return $matches[2];
-               }
-
-               return $content;
-       }
-
-       /**
-        * Substitutes a subpart in $content with the content of $subpartContent.
-        *
-        * @param string $content Content with subpart wrapped in fx. "###CONTENT_PART###" inside.
-        * @param string $marker Marker string, eg. "###CONTENT_PART###
-        * @param array $subpartContent If $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the content of the subpart (fetched by getSubpart())
-        * @param bool $recursive If $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted!
-        * @param bool $keepMarker If set, the marker around the subpart is not removed, but kept in the output
-        *
-        * @return string Processed input content
-        */
-       static public function substituteSubpart($content, $marker, $subpartContent, $recursive = TRUE, $keepMarker = FALSE) {
-               $start = strpos($content, $marker);
-               if ($start === FALSE) {
-                       return $content;
-               }
-               $startAM = $start + strlen($marker);
-               $stop = strpos($content, $marker, $startAM);
-               if ($stop === FALSE) {
-                       return $content;
-               }
-               $stopAM = $stop + strlen($marker);
-               $before = substr($content, 0, $start);
-               $after = substr($content, $stopAM);
-               $between = substr($content, $startAM, $stop - $startAM);
-               if ($recursive) {
-                       $after = self::substituteSubpart($after, $marker, $subpartContent, $recursive, $keepMarker);
-               }
-               if ($keepMarker) {
-                       $matches = array();
-                       if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
-                               $before .= $marker . $matches[1];
-                               $between = $matches[2];
-                               $after = $matches[3] . $marker . $after;
-                       } elseif (preg_match('/^(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
-                               $before .= $marker;
-                               $between = $matches[1];
-                               $after = $matches[2] . $marker . $after;
-                       } elseif (preg_match('/^([^\\<]*\\-\\-\\>)(.*)$/s', $between, $matches) === 1) {
-                               $before .= $marker . $matches[1];
-                               $between = $matches[2];
-                               $after = $marker . $after;
-                       } else {
-                               $before .= $marker;
-                               $after = $marker . $after;
-                       }
-               } else {
-                       $matches = array();
-                       if (preg_match('/^(.*)\\<\\!\\-\\-[^\\>]*$/s', $before, $matches) === 1) {
-                               $before = $matches[1];
-                       }
-                       if (is_array($subpartContent)) {
-                               $matches = array();
-                               if (preg_match('/^([^\\<]*\\-\\-\\>)(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
-                                       $between = $matches[2];
-                               } elseif (preg_match('/^(.*)(\\<\\!\\-\\-[^\\>]*)$/s', $between, $matches) === 1) {
-                                       $between = $matches[1];
-                               } elseif (preg_match('/^([^\\<]*\\-\\-\\>)(.*)$/s', $between, $matches) === 1) {
-                                       $between = $matches[2];
-                               }
-                       }
-                       $matches = array();
-                       // resetting $matches
-                       if (preg_match('/^[^\\<]*\\-\\-\\>(.*)$/s', $after, $matches) === 1) {
-                               $after = $matches[1];
-                       }
-               }
-               if (is_array($subpartContent)) {
-                       $between = $subpartContent[0] . $between . $subpartContent[1];
-               } else {
-                       $between = $subpartContent;
-               }
-
-               return $before . $between . $after;
-       }
-
-       /**
-        * Substitues multiple subparts at once
-        *
-        * @param string $content The content stream, typically HTML template content.
-        * @param array $subpartsContent The array of key/value pairs being subpart/content values used in the substitution. For each element in this array the function will substitute a subpart in the content stream with the content.
-        *
-        * @return string The processed HTML content string.
-        */
-       static public function substituteSubpartArray($content, array $subpartsContent) {
-               foreach ($subpartsContent as $subpartMarker => $subpartContent) {
-                       $content = self::substituteSubpart($content, $subpartMarker, $subpartContent);
-               }
-
-               return $content;
-       }
-
-       /**
-        * Substitutes a marker string in the input content
-        * (by a simple str_replace())
-        *
-        * @param string $content The content stream, typically HTML template content.
-        * @param string $marker The marker string, typically on the form "###[the marker string]###
-        * @param mixed $markContent The content to insert instead of the marker string found.
-        *
-        * @return string The processed HTML content string.
-        * @see substituteSubpart()
-        */
-       static public function substituteMarker($content, $marker, $markContent) {
-               return str_replace($marker, $markContent, $content);
-       }
-
-       /**
-        * Traverses the input $markContentArray array and for each key the marker
-        * by the same name (possibly wrapped and in upper case) will be
-        * substituted with the keys value in the array. This is very useful if you
-        * have a data-record to substitute in some content. In particular when you
-        * use the $wrap and $uppercase values to pre-process the markers. Eg. a
-        * key name like "myfield" could effectively be represented by the marker
-        * "###MYFIELD###" if the wrap value was "###|###" and the $uppercase
-        * boolean TRUE.
-        *
-        * @param string $content The content stream, typically HTML template content.
-        * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
-        * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution
-        * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
-        * @param bool $deleteUnused If set, all unused marker are deleted.
-        *
-        * @return string The processed output stream
-        * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
-        */
-       static public function substituteMarkerArray($content, $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
-               if (is_array($markContentArray)) {
-                       $wrapArr = GeneralUtility::trimExplode('|', $wrap);
-                       $search = array();
-                       $replace = array();
-                       foreach ($markContentArray as $marker => $markContent) {
-                               if ($uppercase) {
-                                       // use strtr instead of strtoupper to avoid locale problems with Turkish
-                                       $marker = strtr($marker, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
-                               }
-                               if (!empty($wrapArr)) {
-                                       $marker = $wrapArr[0] . $marker . $wrapArr[1];
-                               }
-                               $search[] = $marker;
-                               $replace[] = $markContent;
-                       }
-                       $content = str_replace($search, $replace, $content);
-                       unset($search, $replace);
-                       if ($deleteUnused) {
-                               if (empty($wrap)) {
-                                       $wrapArr = array('###', '###');
-                               }
-                               $content = preg_replace('/' . preg_quote($wrapArr[0], '/') . '([A-Z0-9_|\\-]*)' . preg_quote($wrapArr[1], '/') . '/is', '', $content);
-                       }
-               }
-
-               return $content;
-       }
-
-       /**
-        * Replaces all markers and subparts in a template with the content provided in the structured array.
-        *
-        * The array is built like the template with its markers and subparts. Keys represent the marker name and the values the
-        * content.
-        * If the value is not an array the key will be treated as a single marker.
-        * If the value is an array the key will be treated as a subpart marker.
-        * Repeated subpart contents are of course elements in the array, so every subpart value must contain an array with its
-        * markers.
-        *
-        * $markersAndSubparts = array (
-        *    '###SINGLEMARKER1###' => 'value 1',
-        *    '###SUBPARTMARKER1###' => array(
-        *        0 => array(
-        *            '###SINGLEMARKER2###' => 'value 2',
-        *        ),
-        *        1 => array(
-        *            '###SINGLEMARKER2###' => 'value 3',
-        *        )
-        *    ),
-        *    '###SUBPARTMARKER2###' => array(
-        *    ),
-        * )
-        * Subparts can be nested, so below the 'SINGLEMARKER2' it is possible to have another subpart marker with an array as the
-        * value, which in its turn contains the elements of the sub-subparts.
-        * Empty arrays for Subparts will cause the subtemplate to be cleared.
-        *
-        * @static
-        *
-        * @param string $content The content stream, typically HTML template content.
-        * @param array $markersAndSubparts The array of single markers and subpart contents.
-        * @param string $wrap A wrap value - [part1] | [part2] - for the markers before substitution.
-        * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
-        * @param bool $deleteUnused If set, all unused single markers are deleted.
-        *
-        * @return string The processed output stream
-        */
-       static public function substituteMarkerAndSubpartArrayRecursive($content, array $markersAndSubparts, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
-               $wraps = GeneralUtility::trimExplode('|', $wrap);
-               $singleItems = array();
-               $compoundItems = array();
-               // Split markers and subparts into separate arrays
-               foreach ($markersAndSubparts as $markerName => $markerContent) {
-                       if (is_array($markerContent)) {
-                               $compoundItems[] = $markerName;
-                       } else {
-                               $singleItems[$markerName] = $markerContent;
-                       }
-               }
-               $subTemplates = array();
-               $subpartSubstitutes = array();
-               // Build a cache for the sub template
-               foreach ($compoundItems as $subpartMarker) {
-                       if ($uppercase) {
-                               // Use strtr instead of strtoupper to avoid locale problems with Turkish
-                               $subpartMarker = strtr($subpartMarker, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
-                       }
-                       if (!empty($wraps)) {
-                               $subpartMarker = $wraps[0] . $subpartMarker . $wraps[1];
-                       }
-                       $subTemplates[$subpartMarker] = self::getSubpart($content, $subpartMarker);
-               }
-               // Replace the subpart contents recursively
-               foreach ($compoundItems as $subpartMarker) {
-                       $completeMarker = $subpartMarker;
-                       if ($uppercase) {
-                               // use strtr instead of strtoupper to avoid locale problems with Turkish
-                               $completeMarker = strtr($completeMarker, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
-                       }
-                       if (!empty($wraps)) {
-                               $completeMarker = $wraps[0] . $completeMarker . $wraps[1];
-                       }
-                       if (!empty($markersAndSubparts[$subpartMarker])) {
-                               foreach ($markersAndSubparts[$subpartMarker] as $partialMarkersAndSubparts) {
-                                       $subpartSubstitutes[$completeMarker] .= self::substituteMarkerAndSubpartArrayRecursive($subTemplates[$completeMarker],
-                                               $partialMarkersAndSubparts, $wrap, $uppercase, $deleteUnused);
-                               }
-                       } else {
-                               $subpartSubstitutes[$completeMarker] = '';
-                       }
-               }
-               // Substitute the single markers and subparts
-               $result = self::substituteSubpartArray($content, $subpartSubstitutes);
-               $result = self::substituteMarkerArray($result, $singleItems, $wrap, $uppercase, $deleteUnused);
-
-               return $result;
-       }
-}
index 06af2c6..61fe49c 100644 (file)
@@ -5,7 +5,7 @@ Deprecation: #69262 - Move marker substitution functionality to own class
 Description
 ===========
 
-The marker substitution functionality has been moved from core/Classes/Html/HtmlParser.php to it's own class core/Classes/Utility/MarkerUtility.php
+The marker substitution functionality has been moved from core/Classes/Html/HtmlParser.php to it's own class core/Classes/Service/MarkerBasedTemplateService.php
 
 The following methods within HtmlParser have been marked as deprecated.
 
@@ -34,13 +34,14 @@ Extensions that call these PHP methods directly.
 Migration
 =========
 
-Change the use statement from TYPO3\CMS\Core\Html\HtmlParser to TYPO3\CMS\Core\Utility\MarkerUtility and change the class name of the static function calls from HtmlParser to MarkerUtility.
+Change the use statement from TYPO3\CMS\Core\Html\HtmlParser to TYPO3\CMS\Core\Service\MarkerBasedTemplateService and create an instance of this service class. The methods are not static anymore, but named as before.
 
 .. code-block:: php
 
-       MarkerUtility::getSubpart()
-       MarkerUtility::substituteSubpart()
-       MarkerUtility::substituteSubpartArray()
-       MarkerUtility::substituteMarker()
-       MarkerUtility::substituteMarkerArray()
-       MarkerUtility::substituteMarkerAndSubpartArrayRecursive()
+       $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+       $templateService->getSubpart()
+       $templateService->substituteSubpart()
+       $templateService->substituteSubpartArray()
+       $templateService->substituteMarker()
+       $templateService->substituteMarkerArray()
+       $templateService->substituteMarkerAndSubpartArrayRecursive()
diff --git a/typo3/sysext/core/Tests/Unit/Service/MarkerBasedTemplateServiceTest.php b/typo3/sysext/core/Tests/Unit/Service/MarkerBasedTemplateServiceTest.php
new file mode 100644 (file)
index 0000000..76105d8
--- /dev/null
@@ -0,0 +1,596 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Service;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Unit test for marker utility
+ */
+class MarkerBasedTemplateServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+
+       /**
+        * @var MarkerBasedTemplateService
+        */
+       protected $templateService;
+
+       public function setUp() {
+               $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+       }
+
+       /**
+        * Data provider for getSubpart
+        *
+        * @return array
+        */
+       public function getSubpartDataProvider() {
+               return array(
+                       'No start marker' => array(
+                               '<body>text</body>',
+                               '###SUBPART###',
+                               ''
+                       ),
+                       'No stop marker' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->
+text
+</body>',
+                               '###SUBPART###',
+                               ''
+                       ),
+                       'Start and stop marker in HTML comment' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->
+text
+<!-- ###SUBPART### End -->
+</body>',
+                               '###SUBPART###',
+                               '
+text
+'
+                       ),
+                       'Stop marker in HTML comment' => array(
+                               '<body>
+###SUBPART###
+text
+<!-- ###SUBPART### End -->
+</body>',
+                               '###SUBPART###',
+                               '
+text
+'
+                       ),
+                       'Start marker in HTML comment' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->
+text
+###SUBPART###
+</body>',
+                               '###SUBPART###',
+                               '
+text
+'
+                       ),
+                       'Start and stop marker direct' => array(
+                               '<body>
+###SUBPART###
+text
+###SUBPART###
+</body>',
+                               '###SUBPART###',
+                               '
+text
+'
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @param string $content
+        * @param string $marker
+        * @param string $expected
+        * @dataProvider getSubpartDataProvider
+        */
+       public function getSubpart($content, $marker, $expected) {
+               $this->assertSame($expected, $this->templateService->getSubpart($content, $marker));
+       }
+
+       /**
+        * Data provider for substituteSubpart
+        *
+        * @return array
+        */
+       public function substituteSubpartDataProvider() {
+               return array(
+                       'No start marker' => array(
+                               '<body>text</body>',
+                               '###SUBPART###',
+                               'hello',
+                               FALSE,
+                               FALSE,
+                               '<body>text</body>'
+                       ),
+                       'No stop marker' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->
+text
+</body>',
+                               '###SUBPART###',
+                               'hello',
+                               FALSE,
+                               FALSE,
+                               '<body>
+<!-- ###SUBPART### Start -->
+text
+</body>',
+                       ),
+                       'Start and stop marker in HTML comment' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->
+text
+<!-- ###SUBPART### End -->
+</body>',
+                               '###SUBPART###',
+                               'hello',
+                               FALSE,
+                               FALSE,
+                               '<body>
+hello
+</body>'
+                       ),
+                       'Recursive subpart' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->text1<!-- ###SUBPART### End -->
+<!-- ###SUBPART### Start -->text2<!-- ###SUBPART### End -->
+</body>',
+                               '###SUBPART###',
+                               'hello',
+                               TRUE,
+                               FALSE,
+                               '<body>
+hello
+hello
+</body>'
+                       ),
+                       'Keep HTML marker' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->text<!-- ###SUBPART### End -->
+</body>',
+                               '###SUBPART###',
+                               'hello',
+                               FALSE,
+                               TRUE,
+                               '<body>
+<!-- ###SUBPART### Start -->hello<!-- ###SUBPART### End -->
+</body>'
+                       ),
+                       'Keep HTML begin marker' => array(
+                               '<body>
+<!-- ###SUBPART### Start -->text###SUBPART###
+</body>',
+                               '###SUBPART###',
+                               'hello',
+                               FALSE,
+                               TRUE,
+                               '<body>
+<!-- ###SUBPART### Start -->hello###SUBPART###
+</body>'
+                       ),
+                       'Keep HTML end marker' => array(
+                               '<body>
+###SUBPART###text<!-- ###SUBPART### End -->
+</body>',
+                               '###SUBPART###',
+                               'hello',
+                               FALSE,
+                               TRUE,
+                               '<body>
+###SUBPART###hello<!-- ###SUBPART### End -->
+</body>'
+                       ),
+                       'Keep plain marker' => array(
+                               '<body>
+###SUBPART###text###SUBPART###
+</body>',
+                               '###SUBPART###',
+                               'hello',
+                               FALSE,
+                               TRUE,
+                               '<body>
+###SUBPART###hello###SUBPART###
+</body>'
+                       ),
+                       'Wrap around' => array(
+                               '<body>
+###SUBPART###text###SUBPART###
+</body>',
+                               '###SUBPART###',
+                               array('before-', '-after'),
+                               FALSE,
+                               TRUE,
+                               '<body>
+###SUBPART###before-text-after###SUBPART###
+</body>'
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @param string $content
+        * @param string $marker
+        * @param array $subpartContent
+        * @param bool $recursive
+        * @param bool $keepMarker
+        * @param string $expected
+        * @dataProvider substituteSubpartDataProvider
+        */
+       public function substituteSubpart($content, $marker, $subpartContent, $recursive, $keepMarker, $expected) {
+               $this->assertSame($expected, $this->templateService->substituteSubpart($content, $marker, $subpartContent, $recursive, $keepMarker));
+       }
+
+       /**
+        * Data provider for substituteMarkerArray
+        */
+       public function substituteMarkerArrayDataProvider() {
+               return array(
+                       'Upper case marker' => array(
+                               'This is ###MARKER1### and this is ###MARKER2###',
+                               array('###MARKER1###' => 'marker 1',
+                                       '###MARKER2###' => 'marker 2'),
+                               '',
+                               FALSE,
+                               FALSE,
+                               'This is marker 1 and this is marker 2'
+                       ),
+                       'Lower case marker' => array(
+                               'This is ###MARKER1### and this is ###MARKER2###',
+                               array('###marker1###' => 'marker 1',
+                                       '###marker2###' => 'marker 2'),
+                               '',
+                               TRUE,
+                               FALSE,
+                               'This is marker 1 and this is marker 2'
+                       ),
+                       'Upper case marker without hash mark' => array(
+                               'This is ###MARKER1### and this is ###MARKER2###',
+                               array('MARKER1' => 'marker 1',
+                                       'MARKER2' => 'marker 2'),
+                               '###|###',
+                               FALSE,
+                               FALSE,
+                               'This is marker 1 and this is marker 2'
+                       ),
+                       'Upper case marker with another hash mark' => array(
+                               'This is *MARKER1* and this is *MARKER2*',
+                               array('MARKER1' => 'marker 1',
+                                       'MARKER2' => 'marker 2'),
+                               '*|*',
+                               FALSE,
+                               FALSE,
+                               'This is marker 1 and this is marker 2'
+                       ),
+                       'Upper case marker with unused marker' => array(
+                               'This is ###MARKER1### and this is ###MARKER2### ###UNUSED###',
+                               array('###MARKER1###' => 'marker 1',
+                                       '###MARKER2###' => 'marker 2'),
+                               '',
+                               FALSE,
+                               FALSE,
+                               'This is marker 1 and this is marker 2 ###UNUSED###'
+                       ),
+                       'Upper case marker with unused marker deleted' => array(
+                               'This is ###MARKER1### and this is ###MARKER2### ###UNUSED###',
+                               array('###MARKER1###' => 'marker 1',
+                                       '###MARKER2###' => 'marker 2'),
+                               '',
+                               FALSE,
+                               TRUE,
+                               'This is marker 1 and this is marker 2 '
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider substituteMarkerArrayDataProvider
+        * @param string $content The content stream, typically HTML template content.
+        * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
+        * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution
+        * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
+        * @param bool $deleteUnused If set, all unused marker are deleted.
+        * @param string $expected
+        */
+       public function substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused, $expected) {
+               $this->assertSame($expected, $this->templateService->substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused));
+       }
+
+       /**
+        * Data provider for substituteMarker
+        */
+       public function substituteMarkerDataProvider() {
+               return array(
+                       'Single marker' => array(
+                               'This is a ###SAMPLE### text',
+                               '###SAMPLE###',
+                               'simple',
+                               'This is a simple text'
+                       ),
+                       'Double marker' => array(
+                               'This is a ###SAMPLE### text with a ###SAMPLE### content',
+                               '###SAMPLE###',
+                               'simple',
+                               'This is a simple text with a simple content'
+                       ),
+               );
+       }
+
+       /**
+        * @dataProvider substituteMarkerDataProvider
+        * @param string $content The content stream, typically HTML template content.
+        * @param string $marker The marker string, typically on the form "###[the marker string]###
+        * @param mixed $markContent The content to insert instead of the marker string found.
+        * @param string $expected The expected result of the substitution
+        */
+       public function substituteMarker($content, $marker, $markContent, $expected) {
+               $this->assertSame($expected, $this->templateService->substituteMarker($content, $marker, $markContent));
+       }
+
+       /**
+        * Data provider for substituteSubpartArray
+        *
+        * @return array
+        */
+       public function substituteSubpartArrayDataProvider() {
+               return array(
+                       'Substitute multiple subparts at once with plain marker' => array(
+                               '<body>
+###SUBPART1###text1###SUBPART1###
+###SUBPART2###text2###SUBPART2###
+</body>',
+                               array ('###SUBPART1###' => 'hello',
+                                       '###SUBPART2###' => 'world'),
+                               '<body>
+hello
+world
+</body>'
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @param string $content
+        * @param array $subpartsContent
+        * @param string $expected
+        * @dataProvider substituteSubpartArrayDataProvider
+        */
+       public function substituteSubpartArray($content, array $subpartsContent, $expected) {
+               $this->assertSame($expected, $this->templateService->substituteSubpartArray($content, $subpartsContent));
+       }
+
+       /**
+        * Data provider for substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray
+        *
+        * @return array
+        */
+       public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider() {
+               $template = '###SINGLEMARKER1###
+<!-- ###FOO### begin -->
+<!-- ###BAR### begin -->
+###SINGLEMARKER2###
+<!-- ###BAR### end -->
+<!-- ###FOOTER### begin -->
+###SINGLEMARKER3###
+<!-- ###FOOTER### end -->
+<!-- ###FOO### end -->';
+
+               $expected ='Value 1
+
+
+Value 2.1
+
+Value 2.2
+
+
+Value 3.1
+
+Value 3.2
+
+';
+
+               return array(
+                       'Single marker' => array(
+                               '###SINGLEMARKER###',
+                               array(
+                                       '###SINGLEMARKER###' => 'Value 1'
+                               ),
+                               '',
+                               FALSE,
+                               FALSE,
+                               'Value 1'
+                       ),
+                       'Subpart marker' => array(
+                               $template,
+                               array(
+                                       '###SINGLEMARKER1###' => 'Value 1',
+                                       '###FOO###' => array(
+                                               array(
+                                                       '###BAR###' => array(
+                                                               array(
+                                                                       '###SINGLEMARKER2###' => 'Value 2.1'
+                                                               ),
+                                                               array(
+                                                                       '###SINGLEMARKER2###' => 'Value 2.2'
+                                                               )
+                                                       ),
+                                                       '###FOOTER###' => array(
+                                                               array(
+                                                                       '###SINGLEMARKER3###' => 'Value 3.1'
+                                                               ),
+                                                               array(
+                                                                       '###SINGLEMARKER3###' => 'Value 3.2'
+                                                               )
+                                                       )
+                                               )
+                                       )
+                               ),
+                               '',
+                               FALSE,
+                               FALSE,
+                               $expected
+                       ),
+                       'Subpart marker with wrap' => array(
+                               $template,
+                               array(
+                                       'SINGLEMARKER1' => 'Value 1',
+                                       'FOO' => array(
+                                               array(
+                                                       'BAR' => array(
+                                                               array(
+                                                                       'SINGLEMARKER2' => 'Value 2.1'
+                                                               ),
+                                                               array(
+                                                                       'SINGLEMARKER2' => 'Value 2.2'
+                                                               )
+                                                       ),
+                                                       'FOOTER' => array(
+                                                               array(
+                                                                       'SINGLEMARKER3' => 'Value 3.1'
+                                                               ),
+                                                               array(
+                                                                       'SINGLEMARKER3' => 'Value 3.2'
+                                                               )
+                                                       )
+                                               )
+                                       )
+                               ),
+                               '###|###',
+                               FALSE,
+                               FALSE,
+                               $expected
+                       ),
+                       'Subpart marker with lower marker array keys' => array(
+                               $template,
+                               array(
+                                       '###singlemarker1###' => 'Value 1',
+                                       '###foo###' => array(
+                                               array(
+                                                       '###bar###' => array(
+                                                               array(
+                                                                       '###singlemarker2###' => 'Value 2.1'
+                                                               ),
+                                                               array(
+                                                                       '###singlemarker2###' => 'Value 2.2'
+                                                               )
+                                                       ),
+                                                       '###footer###' => array(
+                                                               array(
+                                                                       '###singlemarker3###' => 'Value 3.1'
+                                                               ),
+                                                               array(
+                                                                       '###singlemarker3###' => 'Value 3.2'
+                                                               )
+                                                       )
+                                               )
+                                       )
+                               ),
+                               '',
+                               TRUE,
+                               FALSE,
+                               $expected
+                       ),
+                       'Subpart marker with unused markers' => array(
+                               $template,
+                               array(
+                                       '###FOO###' => array(
+                                               array(
+                                                       '###BAR###' => array(
+                                                               array(
+                                                                       '###SINGLEMARKER2###' => 'Value 2.1'
+                                                               )
+                                                       ),
+                                                       '###FOOTER###' => array(
+                                                               array(
+                                                                       '###SINGLEMARKER3###' => 'Value 3.1'
+                                                               )
+                                                       )
+                                               )
+                                       )
+                               ),
+                               '',
+                               FALSE,
+                               TRUE,
+                               '
+
+
+Value 2.1
+
+
+Value 3.1
+
+'
+                       ),
+                       'Subpart marker with empty subpart' => array(
+                               $template,
+                               array(
+                                       '###SINGLEMARKER1###' => 'Value 1',
+                                       '###FOO###' => array(
+                                               array(
+                                                       '###BAR###' => array(
+                                                               array(
+                                                                       '###SINGLEMARKER2###' => 'Value 2.1'
+                                                               ),
+                                                               array(
+                                                                       '###SINGLEMARKER2###' => 'Value 2.2'
+                                                               )
+                                                       ),
+                                                       '###FOOTER###' => array()
+                                               )
+                                       )
+                               ),
+                               '',
+                               FALSE,
+                               FALSE,
+                               'Value 1
+
+
+Value 2.1
+
+Value 2.2
+
+
+'
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @param string $template
+        * @param array $markersAndSubparts
+        * @param string $wrap
+        * @param bool $uppercase
+        * @param bool $deleteUnused
+        * @param string $expected
+        * @dataProvider substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider
+        */
+       public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused, $expected) {
+               $this->assertSame($expected, $this->templateService->substituteMarkerAndSubpartArrayRecursive($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused));
+       }
+
+}
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Utility/MarkerUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/MarkerUtilityTest.php
deleted file mode 100644 (file)
index a65dd57..0000000
+++ /dev/null
@@ -1,586 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Unit\Utility;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Utility\MarkerUtility;
-
-/**
- * Unit test for marker utility
- */
-class MarkerUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-
-       /**
-        * Data provider for getSubpart
-        *
-        * @return array
-        */
-       public function getSubpartDataProvider() {
-               return array(
-                       'No start marker' => array(
-                               '<body>text</body>',
-                               '###SUBPART###',
-                               ''
-                       ),
-                       'No stop marker' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->
-text
-</body>',
-                               '###SUBPART###',
-                               ''
-                       ),
-                       'Start and stop marker in HTML comment' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->
-text
-<!-- ###SUBPART### End -->
-</body>',
-                               '###SUBPART###',
-                               '
-text
-'
-                       ),
-                       'Stop marker in HTML comment' => array(
-                               '<body>
-###SUBPART###
-text
-<!-- ###SUBPART### End -->
-</body>',
-                               '###SUBPART###',
-                               '
-text
-'
-                       ),
-                       'Start marker in HTML comment' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->
-text
-###SUBPART###
-</body>',
-                               '###SUBPART###',
-                               '
-text
-'
-                       ),
-                       'Start and stop marker direct' => array(
-                               '<body>
-###SUBPART###
-text
-###SUBPART###
-</body>',
-                               '###SUBPART###',
-                               '
-text
-'
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        * @param string $content
-        * @param string $marker
-        * @param string $expected
-        * @dataProvider getSubpartDataProvider
-        */
-       public function getSubpart($content, $marker, $expected) {
-               $this->assertSame($expected, MarkerUtility::getSubpart($content, $marker));
-       }
-
-       /**
-        * Data provider for substituteSubpart
-        *
-        * @return array
-        */
-       public function substituteSubpartDataProvider() {
-               return array(
-                       'No start marker' => array(
-                               '<body>text</body>',
-                               '###SUBPART###',
-                               'hello',
-                               FALSE,
-                               FALSE,
-                               '<body>text</body>'
-                       ),
-                       'No stop marker' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->
-text
-</body>',
-                               '###SUBPART###',
-                               'hello',
-                               FALSE,
-                               FALSE,
-                               '<body>
-<!-- ###SUBPART### Start -->
-text
-</body>',
-                       ),
-                       'Start and stop marker in HTML comment' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->
-text
-<!-- ###SUBPART### End -->
-</body>',
-                               '###SUBPART###',
-                               'hello',
-                               FALSE,
-                               FALSE,
-                               '<body>
-hello
-</body>'
-                       ),
-                       'Recursive subpart' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->text1<!-- ###SUBPART### End -->
-<!-- ###SUBPART### Start -->text2<!-- ###SUBPART### End -->
-</body>',
-                               '###SUBPART###',
-                               'hello',
-                               TRUE,
-                               FALSE,
-                               '<body>
-hello
-hello
-</body>'
-                       ),
-                       'Keep HTML marker' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->text<!-- ###SUBPART### End -->
-</body>',
-                               '###SUBPART###',
-                               'hello',
-                               FALSE,
-                               TRUE,
-                               '<body>
-<!-- ###SUBPART### Start -->hello<!-- ###SUBPART### End -->
-</body>'
-                       ),
-                       'Keep HTML begin marker' => array(
-                               '<body>
-<!-- ###SUBPART### Start -->text###SUBPART###
-</body>',
-                               '###SUBPART###',
-                               'hello',
-                               FALSE,
-                               TRUE,
-                               '<body>
-<!-- ###SUBPART### Start -->hello###SUBPART###
-</body>'
-                       ),
-                       'Keep HTML end marker' => array(
-                               '<body>
-###SUBPART###text<!-- ###SUBPART### End -->
-</body>',
-                               '###SUBPART###',
-                               'hello',
-                               FALSE,
-                               TRUE,
-                               '<body>
-###SUBPART###hello<!-- ###SUBPART### End -->
-</body>'
-                       ),
-                       'Keep plain marker' => array(
-                               '<body>
-###SUBPART###text###SUBPART###
-</body>',
-                               '###SUBPART###',
-                               'hello',
-                               FALSE,
-                               TRUE,
-                               '<body>
-###SUBPART###hello###SUBPART###
-</body>'
-                       ),
-                       'Wrap around' => array(
-                               '<body>
-###SUBPART###text###SUBPART###
-</body>',
-                               '###SUBPART###',
-                               array('before-', '-after'),
-                               FALSE,
-                               TRUE,
-                               '<body>
-###SUBPART###before-text-after###SUBPART###
-</body>'
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        * @param string $content
-        * @param string $marker
-        * @param array $subpartContent
-        * @param bool $recursive
-        * @param bool $keepMarker
-        * @param string $expected
-        * @dataProvider substituteSubpartDataProvider
-        */
-       public function substituteSubpart($content, $marker, $subpartContent, $recursive, $keepMarker, $expected) {
-               $this->assertSame($expected, MarkerUtility::substituteSubpart($content, $marker, $subpartContent, $recursive, $keepMarker));
-       }
-
-       /**
-        * Data provider for substituteMarkerArray
-        */
-       public function substituteMarkerArrayDataProvider() {
-               return array(
-                       'Upper case marker' => array(
-                               'This is ###MARKER1### and this is ###MARKER2###',
-                               array('###MARKER1###' => 'marker 1',
-                                       '###MARKER2###' => 'marker 2'),
-                               '',
-                               FALSE,
-                               FALSE,
-                               'This is marker 1 and this is marker 2'
-                       ),
-                       'Lower case marker' => array(
-                               'This is ###MARKER1### and this is ###MARKER2###',
-                               array('###marker1###' => 'marker 1',
-                                       '###marker2###' => 'marker 2'),
-                               '',
-                               TRUE,
-                               FALSE,
-                               'This is marker 1 and this is marker 2'
-                       ),
-                       'Upper case marker without hash mark' => array(
-                               'This is ###MARKER1### and this is ###MARKER2###',
-                               array('MARKER1' => 'marker 1',
-                                       'MARKER2' => 'marker 2'),
-                               '###|###',
-                               FALSE,
-                               FALSE,
-                               'This is marker 1 and this is marker 2'
-                       ),
-                       'Upper case marker with another hash mark' => array(
-                               'This is *MARKER1* and this is *MARKER2*',
-                               array('MARKER1' => 'marker 1',
-                                       'MARKER2' => 'marker 2'),
-                               '*|*',
-                               FALSE,
-                               FALSE,
-                               'This is marker 1 and this is marker 2'
-                       ),
-                       'Upper case marker with unused marker' => array(
-                               'This is ###MARKER1### and this is ###MARKER2### ###UNUSED###',
-                               array('###MARKER1###' => 'marker 1',
-                                       '###MARKER2###' => 'marker 2'),
-                               '',
-                               FALSE,
-                               FALSE,
-                               'This is marker 1 and this is marker 2 ###UNUSED###'
-                       ),
-                       'Upper case marker with unused marker deleted' => array(
-                               'This is ###MARKER1### and this is ###MARKER2### ###UNUSED###',
-                               array('###MARKER1###' => 'marker 1',
-                                       '###MARKER2###' => 'marker 2'),
-                               '',
-                               FALSE,
-                               TRUE,
-                               'This is marker 1 and this is marker 2 '
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider substituteMarkerArrayDataProvider
-        * @param string $content The content stream, typically HTML template content.
-        * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
-        * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution
-        * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
-        * @param bool $deleteUnused If set, all unused marker are deleted.
-        * @param string $expected
-        */
-       public function substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused, $expected) {
-               $this->assertSame($expected, MarkerUtility::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused));
-       }
-
-       /**
-        * Data provider for substituteMarker
-        */
-       public function substituteMarkerDataProvider() {
-               return array(
-                       'Single marker' => array(
-                               'This is a ###SAMPLE### text',
-                               '###SAMPLE###',
-                               'simple',
-                               'This is a simple text'
-                       ),
-                       'Double marker' => array(
-                               'This is a ###SAMPLE### text with a ###SAMPLE### content',
-                               '###SAMPLE###',
-                               'simple',
-                               'This is a simple text with a simple content'
-                       ),
-               );
-       }
-
-       /**
-        * @dataProvider substituteMarkerDataProvider
-        * @param string $content The content stream, typically HTML template content.
-        * @param string $marker The marker string, typically on the form "###[the marker string]###
-        * @param mixed $markContent The content to insert instead of the marker string found.
-        * @param string $expected The expected result of the substitution
-        */
-       public function substituteMarker($content, $marker, $markContent, $expected) {
-               $this->assertSame($expected, MarkerUtility::substituteMarker($content, $marker, $markContent));
-       }
-
-       /**
-        * Data provider for substituteSubpartArray
-        *
-        * @return array
-        */
-       public function substituteSubpartArrayDataProvider() {
-               return array(
-                       'Substitute multiple subparts at once with plain marker' => array(
-                               '<body>
-###SUBPART1###text1###SUBPART1###
-###SUBPART2###text2###SUBPART2###
-</body>',
-                               array ('###SUBPART1###' => 'hello',
-                                       '###SUBPART2###' => 'world'),
-                               '<body>
-hello
-world
-</body>'
-                       ),
-               );
-       }
-
-       /**
-        * @test
-        * @param string $content
-        * @param array $subpartsContent
-        * @param string $expected
-        * @dataProvider substituteSubpartArrayDataProvider
-        */
-       public function substituteSubpartArray($content, array $subpartsContent, $expected) {
-               $this->assertSame($expected, MarkerUtility::substituteSubpartArray($content, $subpartsContent));
-       }
-
-       /**
-        * Data provider for substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray
-        *
-        * @return array
-        */
-       public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider() {
-               $template = '###SINGLEMARKER1###
-<!-- ###FOO### begin -->
-<!-- ###BAR### begin -->
-###SINGLEMARKER2###
-<!-- ###BAR### end -->
-<!-- ###FOOTER### begin -->
-###SINGLEMARKER3###
-<!-- ###FOOTER### end -->
-<!-- ###FOO### end -->';
-
-               $expected ='Value 1
-
-
-Value 2.1
-
-Value 2.2
-
-
-Value 3.1
-
-Value 3.2
-
-';
-
-               return array(
-                       'Single marker' => array(
-                               '###SINGLEMARKER###',
-                               array(
-                                       '###SINGLEMARKER###' => 'Value 1'
-                               ),
-                               '',
-                               FALSE,
-                               FALSE,
-                               'Value 1'
-                       ),
-                       'Subpart marker' => array(
-                               $template,
-                               array(
-                                       '###SINGLEMARKER1###' => 'Value 1',
-                                       '###FOO###' => array(
-                                               array(
-                                                       '###BAR###' => array(
-                                                               array(
-                                                                       '###SINGLEMARKER2###' => 'Value 2.1'
-                                                               ),
-                                                               array(
-                                                                       '###SINGLEMARKER2###' => 'Value 2.2'
-                                                               )
-                                                       ),
-                                                       '###FOOTER###' => array(
-                                                               array(
-                                                                       '###SINGLEMARKER3###' => 'Value 3.1'
-                                                               ),
-                                                               array(
-                                                                       '###SINGLEMARKER3###' => 'Value 3.2'
-                                                               )
-                                                       )
-                                               )
-                                       )
-                               ),
-                               '',
-                               FALSE,
-                               FALSE,
-                               $expected
-                       ),
-                       'Subpart marker with wrap' => array(
-                               $template,
-                               array(
-                                       'SINGLEMARKER1' => 'Value 1',
-                                       'FOO' => array(
-                                               array(
-                                                       'BAR' => array(
-                                                               array(
-                                                                       'SINGLEMARKER2' => 'Value 2.1'
-                                                               ),
-                                                               array(
-                                                                       'SINGLEMARKER2' => 'Value 2.2'
-                                                               )
-                                                       ),
-                                                       'FOOTER' => array(
-                                                               array(
-                                                                       'SINGLEMARKER3' => 'Value 3.1'
-                                                               ),
-                                                               array(
-                                                                       'SINGLEMARKER3' => 'Value 3.2'
-                                                               )
-                                                       )
-                                               )
-                                       )
-                               ),
-                               '###|###',
-                               FALSE,
-                               FALSE,
-                               $expected
-                       ),
-                       'Subpart marker with lower marker array keys' => array(
-                               $template,
-                               array(
-                                       '###singlemarker1###' => 'Value 1',
-                                       '###foo###' => array(
-                                               array(
-                                                       '###bar###' => array(
-                                                               array(
-                                                                       '###singlemarker2###' => 'Value 2.1'
-                                                               ),
-                                                               array(
-                                                                       '###singlemarker2###' => 'Value 2.2'
-                                                               )
-                                                       ),
-                                                       '###footer###' => array(
-                                                               array(
-                                                                       '###singlemarker3###' => 'Value 3.1'
-                                                               ),
-                                                               array(
-                                                                       '###singlemarker3###' => 'Value 3.2'
-                                                               )
-                                                       )
-                                               )
-                                       )
-                               ),
-                               '',
-                               TRUE,
-                               FALSE,
-                               $expected
-                       ),
-                       'Subpart marker with unused markers' => array(
-                               $template,
-                               array(
-                                       '###FOO###' => array(
-                                               array(
-                                                       '###BAR###' => array(
-                                                               array(
-                                                                       '###SINGLEMARKER2###' => 'Value 2.1'
-                                                               )
-                                                       ),
-                                                       '###FOOTER###' => array(
-                                                               array(
-                                                                       '###SINGLEMARKER3###' => 'Value 3.1'
-                                                               )
-                                                       )
-                                               )
-                                       )
-                               ),
-                               '',
-                               FALSE,
-                               TRUE,
-                               '
-
-
-Value 2.1
-
-
-Value 3.1
-
-'
-                       ),
-                       'Subpart marker with empty subpart' => array(
-                               $template,
-                               array(
-                                       '###SINGLEMARKER1###' => 'Value 1',
-                                       '###FOO###' => array(
-                                               array(
-                                                       '###BAR###' => array(
-                                                               array(
-                                                                       '###SINGLEMARKER2###' => 'Value 2.1'
-                                                               ),
-                                                               array(
-                                                                       '###SINGLEMARKER2###' => 'Value 2.2'
-                                                               )
-                                                       ),
-                                                       '###FOOTER###' => array()
-                                               )
-                                       )
-                               ),
-                               '',
-                               FALSE,
-                               FALSE,
-                               'Value 1
-
-
-Value 2.1
-
-Value 2.2
-
-
-'
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @param string $template
-        * @param array $markersAndSubparts
-        * @param string $wrap
-        * @param bool $uppercase
-        * @param bool $deleteUnused
-        * @param string $expected
-        * @dataProvider substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider
-        */
-       public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused, $expected) {
-               $this->assertSame($expected, MarkerUtility::substituteMarkerAndSubpartArrayRecursive($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused));
-       }
-
-}
\ No newline at end of file
index af5369d..d5d8672 100755 (executable)
@@ -18,7 +18,6 @@ use TYPO3\CMS\Compatibility6\ContentObject\OffsetTableContentObject;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\FrontendEditing\FrontendEditingController;
 use TYPO3\CMS\Core\Html\HtmlParser;
-use TYPO3\CMS\Core\Utility\MarkerUtility;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Mail\MailMessage;
 use TYPO3\CMS\Core\Resource\Exception;
@@ -30,6 +29,7 @@ use TYPO3\CMS\Core\Resource\FileReference;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -560,6 +560,11 @@ class ContentObjectRenderer {
        protected $typoScriptFrontendController;
 
        /**
+        * @var MarkerBasedTemplateService
+        */
+       protected $templateService;
+
+       /**
         * Indicates that object type is USER.
         *
         * @see ContentObjectRender::$userObjectType
@@ -578,6 +583,7 @@ class ContentObjectRenderer {
        public function __construct(TypoScriptFrontendController $typoScriptFrontendController = NULL) {
                $this->typoScriptFrontendController = $typoScriptFrontendController;
                $this->contentObjectClassMap = $GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'];
+               $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
        }
 
        /**
@@ -1974,21 +1980,21 @@ class ContentObjectRenderer {
         * " World. How are ". The input content string could just as well have
         * been "Hello ###sub1### World. How are ###sub1### you?" and the result
         * would be the same
-        * Wrapper for \TYPO3\CMS\Core\Utility\MarkerUtility::getSubpart which behaves identical
+        * Wrapper for \TYPO3\CMS\Core\Utility\MarkerBasedTemplateService::getSubpart which behaves identical
         *
         * @param string $content The content stream, typically HTML template content.
         * @param string $marker The marker string, typically on the form "###[the marker string]###
         * @return string The subpart found, if found.
         */
        public function getSubpart($content, $marker) {
-               return MarkerUtility::getSubpart($content, $marker);
+               return $this->templateService->getSubpart($content, $marker);
        }
 
        /**
         * Substitute subpart in input template stream.
         * This function substitutes a subpart in $content with the content of
         * $subpartContent.
-        * Wrapper for \TYPO3\CMS\Core\Utility\MarkerUtility::substituteSubpart which behaves identical
+        * Wrapper for \TYPO3\CMS\Core\Utility\MarkerBasedTemplateService::substituteSubpart which behaves identical
         *
         * @param string $content The content stream, typically HTML template content.
         * @param string $marker The marker string, typically on the form "###[the marker string]###
@@ -1997,7 +2003,7 @@ class ContentObjectRenderer {
         * @return string The processed HTML content string.
         */
        public function substituteSubpart($content, $marker, $subpartContent, $recursive = 1) {
-               return MarkerUtility::substituteSubpart($content, $marker, $subpartContent, $recursive);
+               return $this->templateService->substituteSubpart($content, $marker, $subpartContent, $recursive);
        }
 
        /**
@@ -2008,7 +2014,7 @@ class ContentObjectRenderer {
         * @return string The processed HTML content string.
         */
        public function substituteSubpartArray($content, array $subpartsContent) {
-               return MarkerUtility::substituteSubpartArray($content, $subpartsContent);
+               return $this->templateService->substituteSubpartArray($content, $subpartsContent);
        }
 
        /**
@@ -2022,7 +2028,7 @@ class ContentObjectRenderer {
         * @see substituteSubpart()
         */
        public function substituteMarker($content, $marker, $markContent) {
-               return MarkerUtility::substituteMarker($content, $marker, $markContent);
+               return $this->templateService->substituteMarker($content, $marker, $markContent);
        }
 
        /**
@@ -2166,7 +2172,7 @@ class ContentObjectRenderer {
         * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
         */
        public function substituteMarkerArray($content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
-               return MarkerUtility::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
+               return $this->templateService->substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
        }
 
        /**
@@ -2199,7 +2205,7 @@ class ContentObjectRenderer {
         * @return string
         */
        public function substituteMarkerAndSubpartArrayRecursive($content, array $markersAndSubparts, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
-               return MarkerUtility::substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
+               return $this->templateService->substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
        }
 
        /**
index a75ab25..cbeaffc 100644 (file)
@@ -18,9 +18,9 @@ use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MarkerUtility;
 use TYPO3\CMS\Linkvalidator\LinkAnalyzer;
 
 /**
@@ -122,6 +122,11 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
        protected $refreshListHtml = '';
 
        /**
+        * @var MarkerBasedTemplateService
+        */
+       protected $templateService;
+
+       /**
         * Main method of modfuncreport
         *
         * @return string Module content
@@ -237,6 +242,8 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                $this->getPageRenderer()->loadJquery();
                $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Linkvalidator/Linkvalidator');
 
+               $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+
                // Don't access in workspace
                if ($this->getBackendUser()->workspace !== 0) {
                        $this->isAccessibleForCurrentUser = FALSE;
@@ -347,7 +354,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         */
        protected function renderBrokenLinksTable() {
                $brokenLinkItems = '';
-               $brokenLinksTemplate = MarkerUtility::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
+               $brokenLinksTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
                $keyOpt = array();
                if (is_array($this->checkOpt)) {
                        $keyOpt = array_keys($this->checkOpt);
@@ -377,8 +384,8 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                        );
                        if (!empty($records)) {
                                // Display table with broken links
-                               $brokenLinksTemplate = MarkerUtility::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
-                               $brokenLinksItemTemplate = MarkerUtility::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
+                               $brokenLinksTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
+                               $brokenLinksItemTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
 
                                // Table rows containing the broken links
                                $items = array();
@@ -392,12 +399,12 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                } else {
                        $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
                }
-               $brokenLinksTemplate = MarkerUtility::substituteMarkerArray(
+               $brokenLinksTemplate = $this->templateService->substituteMarkerArray(
                        $brokenLinksTemplate,
                        $brokenLinksMarker, '###|###',
                        TRUE
                );
-               return MarkerUtility::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
+               return $this->templateService->substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
        }
 
        /**
@@ -511,7 +518,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                $markerArray['lastcheck'] = sprintf($this->getLanguageService()->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime);
 
                // Return the table html code as string
-               return MarkerUtility::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
+               return $this->templateService->substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
        }
 
        /**
@@ -528,8 +535,8 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                } else {
                        $additionalAttr = ' class="refresh"';
                }
-               $checkOptionsTemplate = MarkerUtility::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
-               $hookSectionTemplate = MarkerUtility::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
+               $checkOptionsTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
+               $hookSectionTemplate = $this->templateService->getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
                $markerArray['statistics_header'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('report.statistics.header'));
                $markerArray['total_count_label'] = BackendUtility::wrapInHelp('linkvalidator', 'checkboxes', $this->getLanguageService()->getLL('overviews.nbtotal'));
                $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'] ?: '0';
@@ -552,7 +559,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                                                        . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . '/>' . '<label for="'
                                                        . $prefix . 'SET_' . $type . '">&nbsp;' . htmlspecialchars($translation) . '</label>';
 
-                                               $hookSectionContent .= MarkerUtility::substituteMarkerArray(
+                                               $hookSectionContent .= $this->templateService->substituteMarkerArray(
                                                        $hookSectionTemplate,
                                                        $hookSectionMarker, '###|###',
                                                        TRUE,
@@ -562,12 +569,12 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                                }
                        }
                }
-               $checkOptionsTemplate = MarkerUtility::substituteSubpart(
+               $checkOptionsTemplate = $this->templateService->substituteSubpart(
                        $checkOptionsTemplate,
                        '###HOOK_SECTION###',
                        $hookSectionContent
                );
-               return MarkerUtility::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
+               return $this->templateService->substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
        }
 
        /**
index 53dc8c6..9a8e986 100644 (file)
@@ -16,10 +16,10 @@ namespace TYPO3\CMS\Linkvalidator\Task;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Mail\MailMessage;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MarkerUtility;
 use TYPO3\CMS\Core\Utility\MailUtility;
 use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Linkvalidator\LinkAnalyzer;
@@ -115,6 +115,11 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
        protected $emailOnBrokenLinkOnly;
 
        /**
+        * @var MarkerBasedTemplateService
+        */
+       protected $templateService;
+
+       /**
         * Get the value of the protected property email
         *
         * @return string Email address to which an email report is sent
@@ -236,6 +241,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
         */
        public function execute() {
                $this->setCliArguments();
+               $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
                $successfullyExecuted = TRUE;
                if (
                        !file_exists(($file = GeneralUtility::getFileAbsFileName($this->emailTemplateFile)))
@@ -253,7 +259,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                        }
                }
                $htmlFile = GeneralUtility::getURL($file);
-               $this->templateMail = MarkerUtility::getSubpart($htmlFile, '###REPORT_TEMPLATE###');
+               $this->templateMail = $this->templateService->getSubpart($htmlFile, '###REPORT_TEMPLATE###');
                // The array to put the content into
                $pageSections = '';
                $this->isDifferentToLastRun = FALSE;
@@ -398,7 +404,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
         * @throws \Exception if required modTsConfig settings are missing
         */
        protected function reportEmail($pageSections, array $modTsConfig) {
-               $content = MarkerUtility::substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
+               $content = $this->templateService->substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
                /** @var array $markerArray */
                $markerArray = array();
                /** @var array $validEmailList */
@@ -421,7 +427,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                                unset($params);
                        }
                }
-               $content = MarkerUtility::substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
+               $content = $this->templateService->substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
                /** @var $mail MailMessage */
                $mail = GeneralUtility::makeInstance(MailMessage::class);
                if (empty($modTsConfig['mail.']['fromemail'])) {
@@ -483,7 +489,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
         * @return string Content of the mail
         */
        protected function buildMail($curPage, $pageList, array $markerArray, array $oldBrokenLink) {
-               $pageSectionHtml = MarkerUtility::getSubpart($this->templateMail, '###PAGE_SECTION###');
+               $pageSectionHtml = $this->templateService->getSubpart($this->templateMail, '###PAGE_SECTION###');
                // Hook
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'] as $userFunc) {
@@ -518,7 +524,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                );
                $content = '';
                if ($markerArray['brokenlinkCount'] > 0) {
-                       $content = MarkerUtility::substituteMarkerArray($pageSectionHtml, $markerArray, '###|###', TRUE, TRUE);
+                       $content = $this->templateService->substituteMarkerArray($pageSectionHtml, $markerArray, '###|###', TRUE, TRUE);
                }
                return $content;
        }
index 02b4241..50f5208 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Version\Hook;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
+use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
@@ -589,8 +590,9 @@ class DataHandlerHook {
                                                $emailMessage = $languageObject->sL($emailMessage);
                                        }
                                }
-                               $emailSubject = \TYPO3\CMS\Core\Utility\MarkerUtility::substituteMarkerArray($emailSubject, $markers, '', TRUE, TRUE);
-                               $emailMessage = \TYPO3\CMS\Core\Utility\MarkerUtility::substituteMarkerArray($emailMessage, $markers, '', TRUE, TRUE);
+                               $templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
+                               $emailSubject = $templateService->substituteMarkerArray($emailSubject, $markers, '', TRUE, TRUE);
+                               $emailMessage = $templateService->substituteMarkerArray($emailMessage, $markers, '', TRUE, TRUE);
                                // Send an email to the recipient
                                /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
                                $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);