Skip to main content

Processor registry

Processors run at upload time. Each processor inspects the uploaded file (stream or temp path) and either annotates the DownloadFile row, rejects the upload, or both. The registry holds an ordered chain. ProcessorChain runs every processor and aggregates the results.

KeyValue
Container keymc_dm.processor_registry
Eventmc_dm_processor_handlers

Built-in processors

IDClassWhat it does
hashHashProcessorComputes SHA-256 of the file. Stores it on DownloadFile.hash_sha256.
sizeSizeProcessorRecords file size in bytes.
mimeMimeProcessorDetects MIME type from content (not extension).
magic_byteMagicByteProcessorValidates the file signature against the category's allowed types.
decompression_bombDecompressionBombProcessorRejects ZIP, RAR, and 7z archives that decompress to absurd ratios.

Interface

namespace MC\DownloadsManager\Processor;

interface FileProcessor
{
public function process(DownloadFile $file, string $tempPath): ProcessorResult;
}

ProcessorResult carries pass or reject plus optional annotations to merge onto the DownloadFile entity (hash, size, detected mime, etc.).

Wiring an adapter

public static function processorHandlers(ProcessorRegistry $registry)
{
$registry->register('your_processor', new YourAddon\Processor\YourProcessor());
}

A rejecting processor causes the upload to fail with HTTP 422 from the Files API and a phrase-keyed error in the public UI.