Skip to content

Conversation

@chrissonntag
Copy link
Contributor

Make allowed file extensions configurable for all file processors

Description

This pull request addresses the issue #337 "Feature Request: Make allowed file extensions configurable". By introducing configurable allowed file extensions, users can now customize which file extensions each processor handles without modifying source code.
The previous defined, hardcoded file extensions serve as default values, but can now be customized to the user's extend.

Changes

Fluid Processor

  • Created FluidProcessorOption with ALLOWED_FILE_EXTENSIONS constant
  • Implemented FluidFormatConfiguration class
  • Updated FluidFileProcessor to read from configuration
  • Added to application configuration

TypoScript Processor

  • Added ALLOWED_FILE_EXTENSIONS constant to TypoScriptProcessorOption
  • Updated TypoScriptPrettyPrinterFormatConfiguration to accept and manage allowed file extensions
  • Modified TypoScriptFileProcessor to use strict comparison and read from configuration

Yaml Processor

  • Created YamlProcessorOption with ALLOWED_FILE_EXTENSIONS constant
  • Implemented YamlFormatConfiguration class for managing allowed extensions
  • Updated YamlFileProcessor to use the new configuration class
  • Modified application configuration to inject the format configuration

Xml Processor

  • Added ALLOWED_FILE_EXTENSIONS constant to XmlProcessorOption
  • Created XmlFormatConfiguration class
  • Updated XmlFileProcessor to use configuration and strict comparison
  • Integrated into application configuration

Commits

  1. [FEATURE] Introduce FluidFormatConfiguration and update FluidFileProcessor - Adds configuration for Fluid processor
  2. [FEATURE] Add XmlFormatConfiguration and integrate into XmlFileProcessor - Adds configuration for Xml processor
  3. [FEATURE] Implement YamlFormatConfiguration and integrate into YamlFileProcessor - Adds configuration for Yaml processor
  4. [FEATURE] Enhance TypoScript configuration options - Adds configuration for TypoScript processor
  5. [CLEANUP] Apply rector rule NarrowTooWideReturnTypeRector to StatementCollectingVisitor - Cosmetic code improvement

Verification

To verify the changes:

  1. Run composer local:contribute to ensure all code quality checks pass
  2. Test configuration by setting allowed file extensions via Fractor parameters
  3. Confirm processors now respect configured extensions instead of hardcoded ones

Example

A simplified example configuration regarding the new configuration options might look like the following:

use a9f\Fractor\Configuration\FractorConfiguration;
use a9f\FractorFluid\Configuration\FluidProcessorOption;
use a9f\FractorTypoScript\Configuration\TypoScriptProcessorOption;
use a9f\FractorXml\Configuration\XmlProcessorOption;
use a9f\FractorYaml\Configuration\YamlProcessorOption;

return FractorConfiguration::configure()
    ->withOptions([
        FluidProcessorOption::ALLOWED_FILE_EXTENSIONS => ['html'],
        TypoScriptProcessorOption::ALLOWED_FILE_EXTENSIONS => ['typoscript', 'tsconfig', 'tss', 'tsc'],
        XmlProcessorOption::ALLOWED_FILE_EXTENSIONS => ['xml', 'xlf'],
        YamlProcessorOption::ALLOWED_FILE_EXTENSIONS => ['yaml', 'yml'],
    ]);

…essor

🌟 Add FluidFormatConfiguration class to manage allowed file extensions.
🔧 Update FluidFileProcessor to utilize FluidFormatConfiguration for file extension handling.
✨ Added 'allowedFileExtensions' to TypoScriptProcessorOption for better file handling.
🔧 Updated TypoScriptFileProcessor to use strict comparison for file extension checks.
✨ Introduced XmlFormatConfiguration for managing allowed file extensions.
🔧 Updated XmlFileProcessor to utilize XmlFormatConfiguration for file extension validation.
…leProcessor

✨ Add YamlFormatConfiguration class for managing allowed file extensions.
🔧 Update YamlFileProcessor to utilize YamlFormatConfiguration for file extension handling.
@simonschaufi
Copy link
Collaborator

Please drop the cleanup commit and then rebase. I have fixed that already.

@chrissonntag
Copy link
Contributor Author

LOL, 3rd time is the charm :D
This PR is being succeeded by #343

@chrissonntag chrissonntag deleted the feature/configurable-allowed-file-extensions branch October 1, 2025 18:56
@simonschaufi
Copy link
Collaborator

I wonder what you are doing and why you just can't rebase your PR.

@chrissonntag
Copy link
Contributor Author

I just found it easier to create a new branch and cherry-pick those commits to it. But that's just my confused brain 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants