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
  6. [TASK] Bump tivie/htaccess-parser from ^0.3.0 to ^0.4.0 - Dependency update due to composer local:contribute

The last two commits are cosmetic changes required to maintain code quality standards.

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.
✨ 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.
✨ Added 'allowedFileExtensions' to TypoScriptProcessorOption for better file handling.
🔧 Updated TypoScriptFileProcessor to use strict comparison for file extension checks.
@simonschaufi
Copy link
Collaborator

Thank you for this amazing pull request! That is really the quality that I would expect!

One small wish would be to extract the bump commit into a separate PR. Could you do that please? Then I can merge that independently.

@chrissonntag
Copy link
Contributor Author

Thanks and you welcome. We are using Fractor regularly since a couple months now and are delighted by it and to contribute to it.
I will decouple the commits sometime tomorrow then and thus will send another PR

@chrissonntag
Copy link
Contributor Author

Succeeded by #341 and therefore closed

@chrissonntag chrissonntag deleted the feature/configure-allowed-file-extensions branch October 1, 2025 18:41
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