From f28ddb820ba31160d60ef30e2944acc97c353686 Mon Sep 17 00:00:00 2001
From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com>
Date: Thu, 22 Jun 2023 21:20:51 +0200
Subject: [PATCH] Recursively run through style-manager bundle-configurations
within the project template path
---
.gitignore | 10 ++++++++
composer.json | 48 +++++++++++++++++++++----------------
docs/BUNDLE_CONFIG.md | 14 ++++++++---
src/StyleManager/Config.php | 7 +++---
4 files changed, 52 insertions(+), 27 deletions(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a01604a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+# Composer
+/composer.lock
+/vendor/
+
+# PhpUnit
+/.phpunit.result.cache
+/phpunit.xml
+
+# IDE
+/.idea
diff --git a/composer.json b/composer.json
index 64d742f..c364f3f 100644
--- a/composer.json
+++ b/composer.json
@@ -1,37 +1,36 @@
{
- "name":"oveleon/contao-component-style-manager",
- "type":"contao-bundle",
- "description":"Style and CSS-Class Manager for Contao Open Source CMS",
- "keywords":["contao","styles","css","manager"],
- "homepage":"https://www.oveleon.de/stylemanager.html",
- "license":"MIT",
- "authors":[
+ "name": "oveleon/contao-component-style-manager",
+ "type": "contao-bundle",
+ "description": "Style and CSS-Class Manager for Contao Open Source CMS",
+ "keywords": ["contao", "styles", "css", "manager"],
+ "homepage": "https://www.oveleon.de/stylemanager.html",
+ "license": "MIT",
+ "authors": [
{
- "name":"Oveleon",
- "homepage":"https://oveleon.de/",
- "role":"Developer"
+ "name": "Oveleon",
+ "homepage": "https://oveleon.de/",
+ "role": "Developer"
},
{
- "name":"Daniele Sciannimanica",
- "homepage":"https://github.com/doishub",
- "role":"Developer"
+ "name": "Daniele Sciannimanica",
+ "homepage": "https://github.com/doishub",
+ "role": "Developer"
}
],
- "require":{
- "php":"^7.4 || ^8.0",
+ "require": {
+ "php": "^8.0",
"ext-json": "*",
"ext-dom": "*",
- "contao/core-bundle":"^4.13 || ^5.1"
+ "contao/core-bundle": "^4.13 || ^5.1"
},
"require-dev": {
- "contao/manager-plugin": "^2.0"
+ "contao/manager-plugin": "^2.3.1"
},
"conflict": {
"contao/core": "*",
- "contao/core-bundle": "4.4.1",
"contao/manager-plugin": "<2.0 || >=3.0"
},
- "autoload":{
+ "autoload": {
"psr-4": {
"Oveleon\\ContaoComponentStyleManager\\": "src/"
},
@@ -45,10 +44,17 @@
"src/Resources/contao/templates/"
]
},
- "extra":{
+ "extra": {
"branch-alias": {
- "dev-master": "3.1.x-dev"
+ "dev-master": "3.3.x-dev"
},
"contao-manager-plugin": "Oveleon\\ContaoComponentStyleManager\\ContaoManager\\Plugin"
+ },
+ "config": {
+ "allow-plugins": {
+ "contao-components/installer": true,
+ "php-http/discovery": true,
+ "contao/manager-plugin": true
+ }
}
}
diff --git a/docs/BUNDLE_CONFIG.md b/docs/BUNDLE_CONFIG.md
index 3690262..1f0da6b 100644
--- a/docs/BUNDLE_CONFIG.md
+++ b/docs/BUNDLE_CONFIG.md
@@ -9,12 +9,20 @@
---
# Bundle-Configurations
-Instead of the import function, from version 3, configurations can be automatically provided by other bundles. For the deployment, a configuration file, which can be exported via the StyleManager, must be stored under `contao/templates` of the bundle. The file needs to start with `style-manager-`. If the automatic import of these configuration files is not prevented (allowed by default), archives and CSS groups are automatically added to the defined areas.
+Instead of the import function, from version 3, configurations can be automatically provided by other bundles.
-To prevent dynamic configurations from being read in, you can make the following configuration:
+## Configuration files
+For the deployment, a configuration file, which can be exported via the StyleManager, must be stored under `/templates`
+or `/templates/*`.
+
+> The filename needs to start with `style-manager-`.
+
+If the automatic import of these configuration files is not prevented (allowed by default),
+archives and CSS groups are automatically added to the defined areas.
+
+To prevent dynamic configurations from being parsed, you can disable it with following configuration:
```yaml
# config.yaml
contao_component_style_manager:
use_bundle_config: false
```
-
diff --git a/src/StyleManager/Config.php b/src/StyleManager/Config.php
index d525542..d1fafea 100644
--- a/src/StyleManager/Config.php
+++ b/src/StyleManager/Config.php
@@ -8,6 +8,7 @@
namespace Oveleon\ContaoComponentStyleManager\StyleManager;
+use Contao\StringUtil;
use Contao\System;
use Oveleon\ContaoComponentStyleManager\Controller\BackendModule\ImportController;
@@ -77,15 +78,15 @@ public static function getBundleConfigurationFiles(): ?array
$arrFiles = System::getContainer()->get('contao.resource_finder')->findIn('templates')->files()->name('style-manager-*.xml');
$arrBundleConfigs = null;
- if($projectTemplates = glob($projectDir . '/templates/style-manager-*.xml'))
+ if ($projectTemplates = array_merge((glob($projectDir . '/templates/style-manager-*.xml') ?: []), (glob($projectDir . '/templates/*/style-manager-*.xml') ?: [])))
{
foreach ($projectTemplates as $template)
{
- $arrBundleConfigs[basename($template) . ' (/templates)'] = str_replace($projectDir, '', $template);
+ $arrBundleConfigs[basename($template) . ' (/'. dirname(StringUtil::striprootdir($template)) .')'] = str_replace($projectDir, '', $template);
}
}
- if($arrFiles->hasResults())
+ if ($arrFiles->hasResults())
{
foreach ($arrFiles as $file)
{