Unlock the full potential of the Batoi RAD Framework by mastering its core array, $this->runData. This comprehensive guide covers all components like errorHandler, request, db, config, session, entity, data, and route, helping developers to build robust applications efficiently.

Introduction

The $this->runData array is the backbone of applications developed on the Batoi RAD Framework. This array contains vital information that is generated and modified during the execution of the application. It holds essential parameters and objects, such as database connections, request and session details, configurations, and more. As an integral part of the Batoi RAD Framework, it helps developers keep track of various application states and makes it easy to handle different layers of an application holistically.

Structure of $this->runData

Below is a breakdown of what each key-value pair in the $this->runData array represents:

Core Runtime

Always available on non-admin routes.

Key Usage Description
config $this->runData['config'] System/app paths and settings (sys, app, dir).
db $this->runData['db'] Database instance.
request $this->runData['request'] Request object with method, get/post, uri, csrf_token (if set).
route $this->runData['route'] Route metadata (h1, meta_title, url, assets_url, path, pagepart, alerts).
ms $this->runData['ms'] Microservicelet metadata (id, uid, name, type, scope, tpl_name).
nav $this->runData['nav'] Navigation groups and role-scoped items.
data $this->runData['data'] Payload set by route/controller for templates.

Entity and Access

Available after login or when session is present.

Key Usage Description
entity.id $this->runData['entity']['id'] Entity ID.
entity.uid $this->runData['entity']['uid'] Entity UID.
entity.fullname $this->runData['entity']['fullname'] Display name.
entity.username $this->runData['entity']['username'] Login identity.
entity.role_id $this->runData['entity']['role_id'] Non-SaaS role ID (legacy key).
entity.nonsaas_role_id $this->runData['entity']['nonsaas_role_id'] Non-SaaS role ID (current).
entity.is_logged_in $this->runData['entity']['is_logged_in'] Boolean login status.
entity.route_access $this->runData['entity']['route_access'] Y/N after access checks.
entity.spaces $this->runData['entity']['spaces'] Map of workspace IDs to role flags when populated.

Workspace Scope

Only for workspace-scoped microservicelets.

Key Usage Description
route.space_id $this->runData['route']['space_id'] Workspace ID resolved from the URL segment.
route.access_scope $this->runData['route']['access_scope'] public/private access scope derived from ms scope.

Alerts and UI Helpers

Optional keys used by themes and templates.

Key Usage Description
route.alert $this->runData['route']['alert'] Alert type (success/info/warning/danger).
route.alert_message $this->runData['route']['alert_message'] Alert message content.
route.backlink $this->runData['route']['backlink'] Optional backlink URL for the page header.

Debug Block

Visible only when dev_debug_flag=Y and debug_block=1 for allowed users.

Key Usage Description
route.debug_block $this->runData['route']['debug_block'] Debug payload rendered by the theme (timing + checkpoints).
debug.checkpoints[] $this->runData['debug']['checkpoints'] Optional checkpoints for perf timing.

Legacy Shapes

Some older themes use these. Prefer the primary keys above.

Key Usage Description
entity.user.id $this->runData['entity']['user']['id' Legacy user id.
entity.user.fullname $this->runData['entity']['user']['fullname'] Legacy fullname.
entity.user.username $this->runData['entity']['user']['username'] Legacy username.
entity.user.role_id $this->runData['entity']['user']['role_id'] Legacy role id.

Conclusion

Understanding $this->runData is crucial for effective development in the Batoi RAD Framework. Its comprehensive structure provides a clear roadmap to different functionalities and states within the application.