Code Duplication    Length = 30-30 lines in 2 locations

typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php 1 location

@@ 156-185 (lines=30) @@
153
     * @return string|null Returns NULL if URL was not processed or the processed URL as a string.
154
     * @throws \RuntimeException if a hook was registered but did not fulfill the correct parameters.
155
     */
156
    protected function processUrl(string $context, string $url, array $typolinkConfiguration = [])
157
    {
158
        $urlProcessors = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlProcessors'] ?? false;
159
        if (!$urlProcessors) {
160
            return $url;
161
        }
162
163
        foreach ($urlProcessors as $identifier => $configuration) {
164
            if (empty($configuration) || !is_array($configuration)) {
165
                throw new \RuntimeException('Missing configuration for URI processor "' . $identifier . '".', 1491130459);
166
            }
167
            if (!is_string($configuration['processor']) || empty($configuration['processor']) || !class_exists($configuration['processor']) || !is_subclass_of($configuration['processor'], UrlProcessorInterface::class)) {
168
                throw new \RuntimeException('The URI processor "' . $identifier . '" defines an invalid provider. Ensure the class exists and implements the "' . UrlProcessorInterface::class . '".', 1491130460);
169
            }
170
        }
171
172
        $orderedProcessors = GeneralUtility::makeInstance(DependencyOrderingService::class)->orderByDependencies($urlProcessors);
173
        $keepProcessing = true;
174
175
        foreach ($orderedProcessors as $configuration) {
176
            /** @var UrlProcessorInterface $urlProcessor */
177
            $urlProcessor = GeneralUtility::makeInstance($configuration['processor']);
178
            $url = $urlProcessor->process($context, $url, $typolinkConfiguration, $this->contentObjectRenderer, $keepProcessing);
179
            if (!$keepProcessing) {
180
                break;
181
            }
182
        }
183
184
        return $url;
185
    }
186
187
    /**
188
     * @return TypoScriptFrontendController

typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php 1 location

@@ 5508-5537 (lines=30) @@
5505
     * @return string|null Returns NULL if URL was not processed or the processed URL as a string.
5506
     * @throws \RuntimeException if a hook was registered but did not fulfill the correct parameters.
5507
     */
5508
    protected function processUrl($context, $url, $typolinkConfiguration = [])
5509
    {
5510
        $urlProcessors = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlProcessors'] ?? [];
5511
        if (empty($urlProcessors)) {
5512
            return $url;
5513
        }
5514
5515
        foreach ($urlProcessors as $identifier => $configuration) {
5516
            if (empty($configuration) || !is_array($configuration)) {
5517
                throw new \RuntimeException('Missing configuration for URI processor "' . $identifier . '".', 1442050529);
5518
            }
5519
            if (!is_string($configuration['processor']) || empty($configuration['processor']) || !class_exists($configuration['processor']) || !is_subclass_of($configuration['processor'], UrlProcessorInterface::class)) {
5520
                throw new \RuntimeException('The URI processor "' . $identifier . '" defines an invalid provider. Ensure the class exists and implements the "' . UrlProcessorInterface::class . '".', 1442050579);
5521
            }
5522
        }
5523
5524
        $orderedProcessors = GeneralUtility::makeInstance(DependencyOrderingService::class)->orderByDependencies($urlProcessors);
5525
        $keepProcessing = true;
5526
5527
        foreach ($orderedProcessors as $configuration) {
5528
            /** @var UrlProcessorInterface $urlProcessor */
5529
            $urlProcessor = GeneralUtility::makeInstance($configuration['processor']);
5530
            $url = $urlProcessor->process($context, $url, $typolinkConfiguration, $this, $keepProcessing);
5531
            if (!$keepProcessing) {
5532
                break;
5533
            }
5534
        }
5535
5536
        return $url;
5537
    }
5538
5539
    /**
5540
     * Creates a href attibute for given $mailAddress.