-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e1699c
commit 371e1f8
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,10 @@ | |
*/ | ||
|
||
use B13\Assetcollector\Resource\ResourceCompressor; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use TYPO3\CMS\Core\Information\Typo3Version; | ||
use TYPO3\CMS\Core\SingletonInterface; | ||
use TYPO3\CMS\Core\TypoScript\FrontendTypoScript; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Utility\PathUtility; | ||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; | ||
|
@@ -218,6 +220,7 @@ public function buildInlineXmlTag(): string | |
. '</symbol>'; | ||
} | ||
} | ||
|
||
if (trim($inlineXml) !== '') { | ||
return '<svg class="tx_assetcollector" aria-hidden="true" style="display: none;" version="1.1" xmlns="http://www.w3.org/2000/svg" ' | ||
. 'xmlns:xlink="http://www.w3.org/1999/xlink">' | ||
|
@@ -255,12 +258,28 @@ public function getTypoScriptValue(string $name): string | |
protected function loadTypoScript(): void | ||
{ | ||
$this->typoScriptConfiguration = []; | ||
$frontendController = $this->getTypoScriptFrontendController(); | ||
if ($frontendController !== null) { | ||
$this->typoScriptConfiguration = $frontendController->tmpl->setup['plugin.']['tx_assetcollector.']['icons.'] ?? []; | ||
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) { | ||
$frontendController = $this->getTypoScriptFrontendController(); | ||
if ($frontendController !== null) { | ||
$this->typoScriptConfiguration = $frontendController->tmpl->setup['plugin.']['tx_assetcollector.']['icons.'] ?? []; | ||
} | ||
} else { | ||
$request = $this->getServerRequest(); | ||
if ($request === null) { | ||
return; | ||
} | ||
/** @var FrontendTypoScript $typoScript */ | ||
$typoScript = $request->getAttribute('frontend.typoscript'); | ||
Check failure on line 272 in Classes/AssetCollector.php GitHub Actions / testsuite (11)
|
||
$setup = $typoScript->getSetupArray(); | ||
$this->typoScriptConfiguration = $setup['plugin.']['tx_assetcollector.']['icons.'] ?? []; | ||
} | ||
} | ||
|
||
protected function getServerRequest(): ?ServerRequestInterface | ||
{ | ||
return $GLOBALS['TYPO3_REQUEST'] ?? null; | ||
} | ||
|
||
protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController | ||
{ | ||
if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"pages" | ||
,"uid","pid","title","slug" | ||
,1,0,"root","/" | ||
"sys_template" | ||
,"uid","pid","root","config" | ||
,1,1,1,"page = PAGE | ||
page.10 = FLUIDTEMPLATE | ||
page.10.templateRootPaths.10 = EXT:assetcollector/Tests/Functional/Frontend/Fixtures/Templates | ||
page.10.templateName = SvgViewHelper.html | ||
plugin.tx_assetcollector.icons.download = EXT:assetcollector/Resources/Public/Icons/Extension.svg | ||
" |
9 changes: 9 additions & 0 deletions
9
Tests/Functional/Frontend/Fixtures/Templates/SvgViewHelper.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html | ||
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" | ||
xmlns:ac="http://typo3.org/ns/B13/Assetcollector/ViewHelpers" | ||
data-namespace-typo3-fluid="true" | ||
> | ||
<f:spaceless> | ||
<ac:svg name="download" /> | ||
</f:spaceless> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace B13\Assetcollector\Tests\Functional\Functional; | ||
|
||
/* | ||
* This file is part of TYPO3 CMS-based extension "assetcollector" by b13. | ||
* | ||
* 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. | ||
*/ | ||
|
||
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
class SvgViewHelperTest extends FunctionalTestCase | ||
{ | ||
protected array $testExtensionsToLoad = ['typo3conf/ext/assetcollector']; | ||
protected array $coreExtensionsToLoad = ['core', 'frontend']; | ||
protected array $pathsToLinkInTestInstance = ['typo3conf/ext/assetcollector/Build/sites' => 'typo3conf/sites']; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function scriptTagForInlineCssIsRendered(): void | ||
{ | ||
$this->importCSVDataSet(__DIR__ . '/Fixtures/SvgViewHelper.csv'); | ||
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/')); | ||
$expected = '<svg><use xlink:href="#icon-Extension"></use></svg>'; | ||
$body = (string)$response->getBody(); | ||
self::assertStringContainsString($expected, $body); | ||
$expected = '<svg class="tx_assetcollector"'; | ||
self::assertStringContainsString($expected, $body); | ||
$expected = '<rect y="0.3" class="st0" width="256" height="256"></rect>'; | ||
self::assertStringContainsString($expected, $body); | ||
} | ||
} |