The Protected Downloads module combines a dedicated download post type, access-checked delivery, optional provider-backed remote files, and assigned-download reads for Bricks layouts. The canonical runtime owner is src/Modules/Downloads/DownloadSystem.php.
Module Gate and Entry Points
- Module flag:
brm_enable_protected_downloads - Bootstrap path:
src/Bootstrap/BootstrapCoordinator.php→DownloadSystem::boot() - Admin page:
admin.php?page=brm-downloads - Bricks element:
src/Elements/ProtectedDownloadElement.php - Assignment owner:
src/Modules/Downloads/DownloadAssignmentService.php
Core Runtime Responsibilities
- register the
brm_downloadpost type - add rewrite rules and handle secure download requests
- boot provider support and the remote file browser
- register meta boxes and save download metadata
- serve either local protected files or signed remote URLs
- create the optional download logs table
Provider Architecture
Remote providers register through src/Modules/Downloads/Providers/ProviderRegistry.php. The current provider set includes Local, S3, Bunny, and GCS adapters. For remote downloads, DownloadSystem asks the active provider for a short-lived signed URL and redirects the browser there after access checks pass.
Assigned Downloads
DownloadAssignmentService owns the relation between content posts and download posts. That is the canonical write and read owner for “downloads assigned to the current post” behavior used by Bricks elements, query filters, meta boxes, and structure quick edit flows.
Secure Delivery Flow
- resolve the requested download
- require a logged-in user for protected delivery
- check access through the BRM download access helper
- log the download when logging is enabled
- serve the local file or redirect to a provider-signed URL
Admin Surfaces
src/Admin/DownloadsAdmin.phpsrc/Admin/DownloadsAdminHandlers.phpsrc/Admin/DownloadsAdminRender.php
These classes own the admin UI transport. They do not become alternate owners for runtime access rules or provider delivery.
Edit Guidance
- Start in
DownloadSystemfor runtime delivery, CPT wiring, or provider boot. - Start in
DownloadAssignmentServicefor assignment persistence and current-post reads. - Start in the provider adapter when the change is provider-specific.