Commit d777e049 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen Committed by Thomas Löffler
Browse files

Simplify the getBaseUrl functional and usages

parent 63d604b5
......@@ -17,12 +17,11 @@ namespace T3o\TerFe2\Controller;
use T3o\Ter\Api\ApiUser;
use T3o\Ter\Api\ExtensionKey;
use T3o\Ter\Api\ExtensionVersion;
use T3o\TerFe2\Domain\Model\Extension;
use T3o\TerFe2\Provider\FileProvider;
use T3o\TerFe2\Utility\ExtensionUtility;
use T3o\TerFe2\Validation\Validator\ComposerNameValidator;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Routing\SiteMatcher;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -216,7 +215,7 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
$metaTagManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry::class)->getManagerForProperty('og:description');
$metaTagManager->addProperty('og:description', $extension->getLastVersion()->getDescription());
$metaTagManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry::class)->getManagerForProperty('og:image');
$metaTagManager->addProperty('og:image', $this->getBaseUrl() . ExtensionUtility::getExtensionIcon($extension->getExtKey(), $extension->getLastVersion()->getVersionString()));
$metaTagManager->addProperty('og:image', $this->getOGImageUrl($extension));
$GLOBALS['TSFE']->page['title'] = 'TYPO3 Extension \'' . $extension->getLastVersion()->getTitle() . '\' (' . $extension->getExtKey() . ')';
}
......@@ -640,11 +639,14 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
*/
private function getBaseUrl()
{
$site = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId(self::ROOT_PAGE_ID);
$url = '';
if ($site instanceof Site) {
$url = $site->getRouter()->generateUri(self::ROOT_PAGE_ID);
}
return $url;
return (string)GeneralUtility::makeInstance(\TYPO3\CMS\Core\Site\SiteFinder::class)->getSiteByPageId($GLOBALS['TSFE']->id)->getBase();
}
/**
* @return string
*/
private function getOGImageUrl(Extension $extension): string
{
return $this->getBaseUrl() . '/' . ExtensionUtility::getExtensionIcon($extension->getExtKey(), $extension->getLastVersion()->getVersionString());
}
}
Supports Markdown
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