-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched from PageRenderer to AssetCollector
- Loading branch information
1 parent
0844b83
commit e98e5d8
Showing
5 changed files
with
65 additions
and
59 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
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,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Quellenform\Iconpack\Hooks; | ||
|
||
/* | ||
* This file is part of the "iconpack" Extension for TYPO3 CMS. | ||
* | ||
* Conceived and written by Stephan Kellermayr | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use Quellenform\Iconpack\IconpackFactory; | ||
use TYPO3\CMS\Core\Http\ApplicationType; | ||
use TYPO3\CMS\Core\Page\AssetCollector; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* AssetRenderer hook to add iconpack assets for FE/BE calls | ||
* | ||
* @internal This is a specific hook implementation and is not considered part of the Public TYPO3 API. | ||
*/ | ||
final class AssetRenderer | ||
{ | ||
|
||
public function addCss() | ||
{ | ||
if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface) { | ||
/** @var IconpackFactory $iconpackFactory */ | ||
$iconpackFactory = GeneralUtility::makeInstance(IconpackFactory::class); | ||
|
||
/** @var AssetCollector $assetCollector */ | ||
$assetCollector = GeneralUtility::makeInstance(AssetCollector::class); | ||
|
||
$styleSheets = []; | ||
if ( | ||
ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend() && | ||
(bool) \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( | ||
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class | ||
)->get('iconpack', 'autoAddAssets') | ||
) { | ||
$styleSheets = $iconpackFactory->queryAssets('css', 'frontend'); | ||
} elseif (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) { | ||
$styleSheets = $iconpackFactory->queryAssets('css', 'backend'); | ||
} | ||
// Add StyleSheets | ||
foreach ($styleSheets as $key => $styleSheet) { | ||
// @extensionScannerIgnoreLine | ||
$assetCollector->addStyleSheet( | ||
'iconpack_' . $key, | ||
$styleSheet, | ||
['media' => 'all'] | ||
); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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