ViewCellRegistry
in package
uses
StaticConfigTrait
View Cell Registry Service
Manages registration and retrieval of view cells from core and plugins. Replaces the event-based cell system for better performance and maintainability.
Table of Contents
Constants
- PLUGIN_TYPE_DETAIL = 'detail'
- PLUGIN_TYPE_JSON = 'json'
- PLUGIN_TYPE_MOBILE_MENU = 'mobile_menu'
- PLUGIN_TYPE_MODAL = 'modal'
- PLUGIN_TYPE_TAB = 'tab'
Properties
- $initialized : bool
- $viewCells : array<string|int, mixed>
Methods
- clear() : void
- Clear all registered view cells (useful for testing)
- getDebugInfo() : array<string|int, mixed>
- Get debug information about registered view cells
- getRegisteredSources() : array<string|int, mixed>
- Get all registered sources
- getViewCells() : array<string|int, mixed>
- Get all registered view cells for a URL and user
- getViewCellsFromSource() : array<string|int, mixed>
- Get view cells from a specific source
- isRegistered() : bool
- Check if a source is registered
- register() : void
- Register view cells from a source (core or plugin)
- unregister() : void
- Remove view cells from a specific source
- cellMatchesRoute() : bool
- Check if a cell configuration matches the current route
- ensureInitialized() : void
- Ensure the registry is initialized This can be used to set up default configurations if needed
- organizeViewCells() : array<string|int, mixed>
- Organize view cells by type and order (same as AppController::organizeViewCells)
- routesMatch() : bool
- Check if two routes match
Constants
PLUGIN_TYPE_DETAIL
public
mixed
PLUGIN_TYPE_DETAIL
= 'detail'
PLUGIN_TYPE_JSON
public
mixed
PLUGIN_TYPE_JSON
= 'json'
PLUGIN_TYPE_MOBILE_MENU
public
mixed
PLUGIN_TYPE_MOBILE_MENU
= 'mobile_menu'
PLUGIN_TYPE_MODAL
public
mixed
PLUGIN_TYPE_MODAL
= 'modal'
PLUGIN_TYPE_TAB
public
mixed
PLUGIN_TYPE_TAB
= 'tab'
Properties
$initialized
private
static bool
$initialized
= false
Whether the registry has been initialized
$viewCells
private
static array<string|int, mixed>
$viewCells
= []
View cells registry
Methods
clear()
Clear all registered view cells (useful for testing)
public
static clear() : void
getDebugInfo()
Get debug information about registered view cells
public
static getDebugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed> —Debug information
getRegisteredSources()
Get all registered sources
public
static getRegisteredSources() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of registered source identifiers
getViewCells()
Get all registered view cells for a URL and user
public
static getViewCells(array<string|int, mixed> $urlParams[, Member|null $user = null ]) : array<string|int, mixed>
Parameters
- $urlParams : array<string|int, mixed>
-
URL parameters from request
- $user : Member|null = null
-
The current user
Return values
array<string|int, mixed> —All matching view cells organized by type
getViewCellsFromSource()
Get view cells from a specific source
public
static getViewCellsFromSource(string $source, array<string|int, mixed> $route[, Member|null $user = null ]) : array<string|int, mixed>
Parameters
- $source : string
-
Source identifier
- $route : array<string|int, mixed>
-
Current route information
- $user : Member|null = null
-
The current user
Return values
array<string|int, mixed> —View cells from the specified source
isRegistered()
Check if a source is registered
public
static isRegistered(string $source) : bool
Parameters
- $source : string
-
Source identifier
Return values
bool —True if registered
register()
Register view cells from a source (core or plugin)
public
static register(string $source, array<string|int, mixed> $cells[, callable|null $callback = null ]) : void
Parameters
- $source : string
-
Source identifier (e.g., 'core', 'Awards', 'Officers')
- $cells : array<string|int, mixed>
-
View cell configurations array
- $callback : callable|null = null
-
Optional callback for dynamic cell generation
unregister()
Remove view cells from a specific source
public
static unregister(string $source) : void
Parameters
- $source : string
-
Source identifier to remove
cellMatchesRoute()
Check if a cell configuration matches the current route
private
static cellMatchesRoute(array<string|int, mixed> $cell, array<string|int, mixed> $urlParams[, Member|null $user = null ]) : bool
Parameters
- $cell : array<string|int, mixed>
-
Cell configuration
- $urlParams : array<string|int, mixed>
-
URL parameters from request
- $user : Member|null = null
-
Current user
Return values
bool —True if cell should be displayed
ensureInitialized()
Ensure the registry is initialized This can be used to set up default configurations if needed
private
static ensureInitialized() : void
organizeViewCells()
Organize view cells by type and order (same as AppController::organizeViewCells)
private
static organizeViewCells(array<string|int, mixed> $viewCells) : array<string|int, mixed>
Parameters
- $viewCells : array<string|int, mixed>
-
Array of view cell configurations
Return values
array<string|int, mixed> —Organized cells by type
routesMatch()
Check if two routes match
private
static routesMatch(array<string|int, mixed> $current, array<string|int, mixed> $valid) : bool
Parameters
- $current : array<string|int, mixed>
-
Current route
- $valid : array<string|int, mixed>
-
Valid route pattern
Return values
bool —True if routes match