Gate registry
Gates run before a sensitive operation — typically file serve, but also download view and other guarded actions. Each gate inspects a GateContext and returns a GateResult: pass, soft-fail (with reason), or hard-fail.
The registry holds an ordered chain. GateChain evaluates gates in registration order and short-circuits on the first hard-fail.
| Key | Value |
|---|---|
| Container key | mc_dm.gate_registry |
| Event | mc_dm_gate_handlers |
Built-in gates
Registered in registration order; the chain short-circuits on the first hard-fail.
| ID | Class | What it checks |
|---|---|---|
permission | MC\DownloadsManager\Gate\PermissionGate | Per-category permissions (viewFiles, download, etc.) via XF\Permission\TreeContentPermissions. |
criteria | MC\DownloadsManager\Gate\CriteriaGate | Per-category criteria gates configured in the AdminCP (user/group/visitor matching). |
password | MC\DownloadsManager\Gate\PasswordGate | Per-download password, with a configurable pass-window before re-prompting. |
hotlink | MC\DownloadsManager\Gate\HotlinkGate | Referrer check to block off-site hotlinking of file URLs. |
captcha | MC\DownloadsManager\Gate\CaptchaGate | CAPTCHA challenge for unauthenticated or low-trust visitors. |
rate_limit | MC\DownloadsManager\Gate\RateLimitGate | Per-visitor request-rate cap on serve operations. |
bandwidth | MC\DownloadsManager\Gate\BandwidthGate | Resolves the visitor's effective bandwidth cap and switches the serve view to a throttled stream. Never fails. |
NSFW filtering ships as a separate add-on (see extensions/nsfw-gate) that registers its own gate via this registry.
Interface
namespace MC\DownloadsManager\Gate;
interface Gate
{
public function evaluate(GateContext $context): GateResult;
}
GateContext carries the visitor, the Download, the DownloadVersion, the DownloadFile (when applicable), and the operation (view, serve, etc.). GateResult is one of pass(), softFail($reason), or hardFail($reason).
Wiring an adapter
public static function gateHandlers(GateRegistry $registry)
{
$registry->register('your_gate', new YourAddon\Gate\YourGate());
}
Subscribe to mc_dm_gate_handlers in code_event_listeners.xml.
Lifecycle events fired
mc_dm_gate_passedfires after a gate returnspass().mc_dm_gate_failedfires after a gate returnssoftFailorhardFail. The event includes theGateResultfor inspection.
See Gate events.