-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 9268c40
Showing
8 changed files
with
486 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Classes/EventListener/PostProcessComponentViewEventListener.php
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,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace StudioMitte\FluidStyleguideEncore\EventListener; | ||
|
||
use Sitegeist\FluidStyleguide\Event\PostProcessComponentViewEvent; | ||
use Ssch\Typo3Encore\Asset\EntrypointLookup; | ||
use Ssch\Typo3Encore\Integration\CacheFactory; | ||
use Ssch\Typo3Encore\Integration\Filesystem; | ||
use Ssch\Typo3Encore\Integration\JsonDecoder; | ||
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class PostProcessComponentViewEventListener | ||
{ | ||
public function __invoke(PostProcessComponentViewEvent $event): void | ||
{ | ||
$configuration = $this->getConfiguration(); | ||
if (empty($configuration)) { | ||
return; | ||
} | ||
$jsonDecoder = new JsonDecoder(); | ||
$io = new Filesystem(); | ||
|
||
$cacheFactory = GeneralUtility::makeInstance(CacheFactory::class); | ||
$entryPointLookup = GeneralUtility::makeInstance(EntrypointLookup::class, $configuration['path'] ?? '', '_styleguide', true, $jsonDecoder, $io, $cacheFactory); | ||
|
||
foreach ($entryPointLookup->getCssFiles($configuration['entryName'] ?? '') as $css) { | ||
$event->addHeaderData(' <link rel="stylesheet" href="' . htmlspecialchars($css) . '" />'); | ||
} | ||
foreach ($entryPointLookup->getJavaScriptFiles('app') as $js) { | ||
$event->addHeaderData('<script src="' . htmlspecialchars($js) . '"></script>'); | ||
} | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getConfiguration(): array | ||
{ | ||
try { | ||
return GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('fluid_styleguide_encore'); | ||
} catch (\Exception $e) { | ||
// do nothing | ||
} | ||
return []; | ||
} | ||
} |
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,14 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: true | ||
|
||
StudioMitte\FluidStyleGuideEncore\: | ||
resource: '../Classes/*' | ||
|
||
StudioMitte\FluidStyleGuideEncore\EventListener\PostProcessComponentViewEventListener: | ||
tags: | ||
- name: event.listener | ||
identifier: 'fluid-styleguide-encore' | ||
event: Sitegeist\FluidStyleguide\Event\PostProcessComponentViewEvent |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# TYPO3 Extension `fluid_styleguide_encore` | ||
|
||
This extension makes it possible to use `EXT:typo3_encore` with `EXT:fluid_styleguide`. | ||
|
||
## Usage | ||
|
||
1. Install extension by using `composer req studiomitte/fluid-styleguide-encore`. | ||
2. Configure the path to the `entrypoint.json` and entryname | ||
|
||
**Done** |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,31 @@ | ||
{ | ||
"name": "studiomitte/fluid-styleguide-encore", | ||
"description": "Make typo3_encore work with fluid_styleguide", | ||
"license": "GPL-2.0-or-later", | ||
"type": "typo3-cms-extension", | ||
"authors": [ | ||
{ | ||
"name": "Georg Ringer", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"typo3/cms-core": "^10 || ^11", | ||
"ssch/typo3-encore": "^4", | ||
"sitegeist/fluid-styleguide": "^2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"StudioMitte\\FluidStyleGuideEncore\\": "Classes" | ||
} | ||
}, | ||
"replace": { | ||
"studiomitte/fluid-styleguide-encore": "self.version", | ||
"typo3-ter/fluid-styleguide-encore": "self.version" | ||
}, | ||
"extra": { | ||
"typo3/cms": { | ||
"extension-key": "fluid_styleguide_encore" | ||
} | ||
} | ||
} |
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,6 @@ | ||
# cat=basic; type=string; label=Path | ||
path = EXT:site-package/Resources/Public/Frontend/entrypoints.json | ||
|
||
# cat=basic; type=string; label=Entryname | ||
entryName = app | ||
|
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
$EM_CONF[$_EXTKEY] = [ | ||
'title' => 'Theme', | ||
'description' => '', | ||
'category' => 'fe', | ||
'author' => 'Georg Ringer', | ||
'author_email' => 'gr@studiomitte.com', | ||
'author_company' => 'StudioMitte', | ||
'state' => 'stable', | ||
'version' => '1.0.0', | ||
'constraints' => [ | ||
'depends' => [ | ||
'typo3' => '10.4.0-11.9.99', | ||
'typo3_encore' => '', | ||
'fluid_styleguide' => '', | ||
], | ||
'conflicts' => [ | ||
], | ||
'suggests' => [ | ||
], | ||
], | ||
'autoload' => [ | ||
'psr-4' => [ | ||
'StudioMitte\\Theme\\' => 'Classes', | ||
], | ||
], | ||
]; |