Commit 3c9cea02 authored by Fabian Galinski's avatar Fabian Galinski 😾
Browse files

[TASK] Usage of the typolink function for the url generation

parent 1eff7f38
......@@ -38,24 +38,6 @@ class ContentElementRendering {
*/
public $cObj;
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
*/
protected $objectManager;
/**
* @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
*/
protected $uriBuilder;
/**
* Construct for this user function
*/
public function __construct() {
$this->objectManager = $objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$this->uriBuilder = $this->objectManager->get('TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder');
}
/**
* Adds parameters to the current content element.
*
......@@ -67,23 +49,10 @@ class ContentElementRendering {
return $content;
}
// Creation of the content link
$contentLink = $this->cObj->data['tx_sgcontentlink_contentlink'];
$contentLinkPageId = (int) $contentLink;
if ($contentLinkPageId > 0) {
$contentLink = $this->uriBuilder->reset()->setTargetPageUid($contentLinkPageId)->build();
} elseif ((stripos($contentLink, 'http://') === false) && (stripos($contentLink, 'https://') === false)) {
$contentLink = 'http://' . $contentLink;
}
if (!$contentLink) {
return $content;
}
// Removal of all links
$content = preg_replace('/<a.+?>/is', '', $content);
$content = str_replace('</a>', '', $content);
return $this->cObj->wrap($content, '<a href="' . $contentLink . '"> | </a>');
return $this->cObj->getTypoLink($content, $this->cObj->data['tx_sgcontentlink_contentlink']);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment