Cubes Architecture (Final)
Overview
Service → data\ Executor → flow + grouping\ Cube (frontend.php) → logic\ Template → render\ Group → runtime (not DB, not editor)
Structure
Modules/Cubes/ - DTO/CubeDTO.php - Service/CubesQueryService.php - Service/CubesService.php - Runtime/CubeExecutor.php - Runtime/TemplateSplitter.php - Runtime/CubeRenderContext.php
Data Flow
DB → CubesQueryService\ → CubesService (normalize + lang fallback)\ → CubeExecutor\ → groupByTypeSequence()\ → renderSingle / renderGroup
Contract
Each cube receives: - \$cube (DTO) - \$data (normalized array) - \$meta (first/last/odd/group) - \$ctx (context)
Each cube ends with: echo cube_view(...)
Group Rendering
Split template using <!--cover-->{=html}
Render: - head (first cube) - loop items - foot (last cube)
Rules
Allowed: - logic in template - missing data - fallback handling
Forbidden: - cube affecting another cube - shared global state
BOX (optional shared context)
\$ctx->box = ['layout' => 'grid'];
TL;DR
Keep core clean. Allow chaos inside cubes.