+
Skip to content

Conversation

chrissonntag
Copy link

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

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.
✨ Implement tests for FluidFormatConfiguration to validate default and custom file extensions.
✨ Implement tests for TypoScriptFileProcessor to validate default and custom file extensions
✨ Implement tests for XmlFileProcessor to validate default and custom file extensions
✨ Implement tests for YamlFileProcessor to validate default and custom file extensions
@chrissonntag
Copy link
Author

I've implemented Unit Tests for the 4 FileProcessors to validate either the default or custom configuration of allowed file extension work accordingly.

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.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载