Skip to content

Commit

Permalink
Merge pull request #88 from oveleon/develop
Browse files Browse the repository at this point in the history
Recursively run through style-manager bundle-configurations within th…
  • Loading branch information
zoglo authored Jun 22, 2023
2 parents dcb4b2e + f28ddb8 commit 04c621c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 27 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Composer
/composer.lock
/vendor/

# PhpUnit
/.phpunit.result.cache
/phpunit.xml

# IDE
/.idea
48 changes: 27 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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/"
},
Expand All @@ -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
}
}
}
14 changes: 11 additions & 3 deletions docs/BUNDLE_CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
7 changes: 4 additions & 3 deletions src/StyleManager/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Oveleon\ContaoComponentStyleManager\StyleManager;

use Contao\StringUtil;
use Contao\System;
use Oveleon\ContaoComponentStyleManager\Controller\BackendModule\ImportController;

Expand Down Expand Up @@ -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) . ' <b>(/templates)</b>'] = str_replace($projectDir, '', $template);
$arrBundleConfigs[basename($template) . ' <b>(/'. dirname(StringUtil::striprootdir($template)) .')</b>'] = str_replace($projectDir, '', $template);
}
}

if($arrFiles->hasResults())
if ($arrFiles->hasResults())
{
foreach ($arrFiles as $file)
{
Expand Down

0 comments on commit 04c621c

Please sign in to comment.