Skip to content

Commit

Permalink
[TASK] Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
georgringer committed Dec 7, 2021
0 parents commit 9268c40
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Classes/EventListener/PostProcessComponentViewEventListener.php
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 [];
}
}
14 changes: 14 additions & 0 deletions Configuration/Services.yaml
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
345 changes: 345 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Readme.md
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**
1 change: 1 addition & 0 deletions Resources/Public/Icons/Extension.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions composer.json
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"
}
}
}
6 changes: 6 additions & 0 deletions ext_conf_template.txt
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

30 changes: 30 additions & 0 deletions ext_emconf.php
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',
],
],
];

0 comments on commit 9268c40

Please sign in to comment.