VOOZH about

URL: https://deepwiki.com/mathsgod/light/4.3.2-appcontroller

⇱ AppController | mathsgod/light | DeepWiki


Loading...
Last indexed: 31 January 2026 (cf9511)
Menu

AppController

Purpose and Scope

The AppController class provides GraphQL mutations and queries for managing application-wide configuration and user-specific preferences. This controller handles system settings stored in the Config model, custom menu definitions, user style preferences, language settings, and session revocation operations.

For authentication-related operations (login, logout, password management), see AuthController. For file system operations, see FileSystemController. For general system queries (permissions, menus from YAML), see Root Query Type.

Sources: src/Controller/AppController.php1-151


GraphQL Operations Overview

The AppController exposes the following GraphQL operations:

OperationTypeAuthenticationAuthorizationPurpose
getAppQueryNoneNoneReturns the root App type
updateAppConfigMutation@Loggedconfig.updateUpdates a single configuration value
updateAppConfigsMutation@Loggedconfig.updateBatch updates multiple configurations
updateAppMenusMutation@Loggedmenu.updateUpdates custom menu definitions
getAppMenusQuery@LoggedNoneReturns custom menus (deprecated)
updateMyStyleMutation@LoggedNoneUpdates a single user style preference
updateMyStylesMutation@LoggedNoneBatch updates user style preferences
updateMyLanguageMutation@LoggedNoneSets user's language preference
updateMyMenuMutation@LoggedNoneUpdates user's menu customization
revokeSessionMutation@LoggedNoneRevokes a specific user session by JWT ID

Sources: src/Controller/AppController.php22-150


Operation Flow Diagram


Sources: src/Controller/AppController.php1-151


System Configuration Management

Configuration Update Operations

The controller provides two methods for updating system configuration stored in the Config model:

Single Configuration Update (updateAppConfig)

Batch Configuration Update (updateAppConfigs)

  • Updates multiple configurations in a single operation
  • Accepts an array of {name, value} objects
  • Clears the entire application cache after updates
  • Requires config.update permission
  • Implementation: src/Controller/AppController.php41-57

Configuration Storage Pattern


Key Implementation Details:

  1. Upsert Pattern: The controller checks if a configuration exists using Config::Get(["name" => $name]). If not found, it creates a new entry with Config::Create(["name" => $name]) src/Controller/AppController.php44-48 src/Controller/AppController.php64-68

  2. Cache Invalidation: After batch configuration updates, the controller calls $app->getCache()->clear() to ensure all cached data (including GraphQL schema cache) reflects the new configuration src/Controller/AppController.php54

  3. Authorization: Both methods require the config.update permission enforced via @Right('config.update') annotation src/Controller/AppController.php37 src/Controller/AppController.php61

Sources: src/Controller/AppController.php35-72


Menu Configuration Management

The controller manages custom menu definitions stored in the Config model under the key "menus".

Update Custom Menus

Operation: updateAppMenus


Retrieve Custom Menus (Deprecated)

Operation: getAppMenus

Storage Format:

  • Menus are stored as a JSON string in Config.value
  • The key is always "menus"
  • Encoding occurs at line 87: $menus->value = json_encode($data)

Sources: src/Controller/AppController.php74-102


User Preference Management

The controller provides mutations for managing user-specific preferences. These operations require authentication (@Logged) but no additional permissions, allowing any authenticated user to customize their own experience.

Style Preferences

User style preferences support arbitrary key-value pairs for frontend customization (themes, layouts, UI settings).

Single Style Update (updateMyStyle)

Batch Style Update (updateMyStyles)

Language Preference

Operation: updateMyLanguage


Menu Customization

Operation: updateMyMenu

User Preference Flow


Sources: src/Controller/AppController.php105-149


Session Management

Session Revocation

Operation: revokeSession

  • Revokes a specific user session by its JWT ID (jti)
  • Only allows users to revoke their own sessions
  • Delegates to User::revokeSession($jti) method
  • Implementation: src/Controller/AppController.php24-27

Key Features:

  1. User Context: Uses #[InjectUser] to ensure only the authenticated user can revoke their own sessions
  2. JWT Identification: Each session is identified by its JWT ID (jti claim)
  3. Immediate Effect: Revocation occurs immediately via cache-based token blacklisting
  4. Audit Trail: The revocation is also recorded in the UserLog table

For details on the revocation mechanism, see JWT Token System and User Model and Sessions.

Sources: src/Controller/AppController.php22-27


Authorization and Security

Permission Model

The controller implements a three-tier authorization model:

Permission LevelOperationsAuthorization
NonegetAppPublic access
AuthenticatedUser preferences, session revocation@Logged annotation
System AdministratorConfiguration updates, menu management@Logged + @Right

Permission Requirements

System Configuration Rights:

Menu Management Rights:

User Preferences:

  • No additional permissions beyond authentication
  • Users can modify their own style, language, and menu preferences
  • Enforced through #[InjectUser] which binds operations to the authenticated user

Security Annotations


Sources: src/Controller/AppController.php23-24 src/Controller/AppController.php36-37 src/Controller/AppController.php60-61 src/Controller/AppController.php75-76 src/Controller/AppController.php106 src/Controller/AppController.php116 src/Controller/AppController.php131 src/Controller/AppController.php140


Integration with Other Systems

Dependency Injection

The controller uses GraphQLite's dependency injection annotations to access system components:

#[Autowire] LightApp $app

#[InjectUser] User $user

Model Interactions


Config Model Integration:

User Model Integration:

Cache Integration:

  • Cache clearing occurs after batch configuration updates to ensure consistency src/Controller/AppController.php54
  • Invalidates GraphQL schema cache, configuration cache, and other cached data

Sources: src/Controller/AppController.php1-151


Related Documentation

For comprehensive understanding of the configuration and preference management system:

Sources: src/Controller/AppController.php1-151