Skip to main content

Gate events

Fired by the controller's gate-chain loop after each gate evaluates, plus a single aggregate event after the full chain passes. Use these to log gate decisions, audit failures, or feed external monitoring without touching gate code.

Events

EventSignatureWhen
mc_dm_gate_passed(GateContext $ctx, GateResult $result, string $key)A gate returned pass(). Fires per gate.
mc_dm_gate_failed(GateContext $ctx, GateResult $result, string $key)A gate did not return pass(). Fires for the first failing gate only — the chain short-circuits.
mc_dm_gate_all_passed(GateContext $ctx)The full chain (permission, criteria, password, hotlink, captcha, rate_limit) passed. Fires once per attempt. Added in 1.0.0.

$key identifies which gate fired and is one of: permission, criteria, password, hotlink, captcha, rate_limit, bandwidth. The GateResult carries getReason() and getContext() so listeners can inspect failure detail without re-evaluating.

Notes

  • mc_dm_gate_passed fires per gate. A request clearing all six gates fires it six times. Subscribe to mc_dm_gate_all_passed instead if you only want one notification per successful attempt.
  • mc_dm_gate_failed short-circuits — later gates do not fire either event.
  • The bandwidth gate is an always-on policy that runs even when a valid download cursor lets the chain skip the challenge gates. It fires mc_dm_gate_passed / mc_dm_gate_failed with $key === 'bandwidth', but does not count toward mc_dm_gate_all_passed (the aggregate fires before the bandwidth check).
  • Moderators with mcDownloadsMod.bypassCriteriaGate skip the criteria gate entirely — no event fires for that gate for them. Counts of "criteria-gate passes per day" will undercount mods.

Example: log gate failures to the audit log

public static function gateFailed(
\MC\DownloadsManager\Gate\GateContext $ctx,
\MC\DownloadsManager\Gate\GateResult $result,
string $key
)
{
\XF::repository('MC\DownloadsManager:AuditLog')->log(
'gate_failed',
'download',
$ctx->getDownload()->download_id,
[
'gate' => $key,
'reason' => $result->getReason(),
'context' => $result->getContext(),
]
);
}

See also: Gate registry.