# Core Framework Systems ## Main_Abstract Middleware System The framework provides application-wide middleware hooks via `Main_Abstract`: ### Implementation 1. **Create `/rsx/main.php`** extending `Main_Abstract` with three methods: - `init()` - Called once during bootstrap - `pre_dispatch(Request $request, array $params)` - Called before any route dispatch - `unhandled_route(Request $request, array $params)` - Called when no route matches 2. **Pre-dispatch flow**: - Main::pre_dispatch() called first - Controller::pre_dispatch() called second - If either returns non-null, dispatch halts with that response 3. **Controller/API Method Signatures**: - All controller methods: `function method_name(Request $request, array $params = [])` - All API methods: `function method_name(Request $request, array $params = [])` - `$params` contains GET query string parameters and URL-extracted route parameters (like `:id`) - POST data is accessed via `$request->post()` or `$request->input()`, NOT in `$params` ## Core JavaScript Classes These classes are ALWAYS available - never check for their existence: - `Rsx_Manifest` - Manifest management - `Rsx_Storage` - Browser storage (session/local) with scoping - `Rsx` - Core framework utilities - All classes in `/app/RSpade/Core/Js/` Use them directly without defensive coding: ```javascript // ✅ GOOD Rsx_Manifest.define(...) // ❌ BAD if (typeof Rsx_Manifest !== 'undefined') { Rsx_Manifest.define(...) } ``` ## Dispatcher System Maps HTTP requests to RSX controllers based on manifest data. ## Autoloader System Provides path-agnostic class loading - classes are found by name, not path. ## Manifest System Indexes all files in `/rsx/` for automatic discovery and loading. ## JQHTML Named Slots (v2.2.112+) Child template syntax changed from `` tags to `content('slotname')` function: - Old: `` (deprecated) - New: `<%= content('header') %>` (v2.2.112+) - Parent syntax: `content` ## JQHTML Slot-Based Template Inheritance (v2.2.108+) When component template contains ONLY slots (no HTML), it automatically inherits parent class template structure: - Enables abstract base components with customizable slots - Child templates define slot-only files to extend parent templates - Parent templates call slots: `<%= content('slotname', data) %>` (data passing supported) - JavaScript class must extend parent: `class Child extends Parent` - Slot names cannot be JavaScript reserved words (enforced by parser) ## JQHTML Define Tag Configuration `` tag supports three attribute types: - `extends="Parent"` - Explicit template inheritance - `$property=value` - Set default this.args values (unquoted=JS expression, quoted=string) - Regular HTML attributes (class, id, tag, data-*) - Enables template-only components without JavaScript classes