ApprovalContextRendererRegistry
in package
Static registry for approval context renderers.
Plugins register renderers keyed by source name. When the approvals UI needs display context for a workflow instance, the registry iterates registered renderers and returns the first match, falling back to a generic default context.
Follows the same static-registry pattern as WorkflowActionRegistry.
Table of Contents
Properties
- $contextCache : array<string, ApprovalContext>
- $initialized : bool
- $renderers : array<string, ApprovalContextRendererInterface>
Methods
- clear() : void
- Clear all registered renderers. Primarily for testing.
- getAllRenderers() : array<string, ApprovalContextRendererInterface>
- Get all registered renderers.
- getDefaultContext() : ApprovalContext
- Build a generic fallback context when no renderer matches.
- getRegisteredSources() : array<int, string>
- Get all registered source identifiers.
- isRegistered() : bool
- Check if a source has a registered renderer.
- register() : void
- Register a renderer for a given source (e.g. 'Authorizations', 'Awards').
- render() : ApprovalContext
- Render approval context for a workflow instance.
- unregister() : void
- Remove the renderer for a specific source.
- contextCacheKey() : string|null
- Build a request-local cache key for persisted workflow instances.
- ensureInitialized() : void
- Ensure the registry is initialized.
Properties
$contextCache
private
static array<string, ApprovalContext>
$contextCache
= []
$initialized
private
static bool
$initialized
= false
$renderers
private
static array<string, ApprovalContextRendererInterface>
$renderers
= []
Methods
clear()
Clear all registered renderers. Primarily for testing.
public
static clear() : void
getAllRenderers()
Get all registered renderers.
public
static getAllRenderers() : array<string, ApprovalContextRendererInterface>
Return values
array<string, ApprovalContextRendererInterface>getDefaultContext()
Build a generic fallback context when no renderer matches.
public
static getDefaultContext(WorkflowInstance $instance) : ApprovalContext
Attempts to load the entity and derive a display name from common naming fields (name, sca_name, title).
Parameters
- $instance : WorkflowInstance
-
Workflow instance
Return values
ApprovalContextgetRegisteredSources()
Get all registered source identifiers.
public
static getRegisteredSources() : array<int, string>
Return values
array<int, string>isRegistered()
Check if a source has a registered renderer.
public
static isRegistered(string $source) : bool
Parameters
- $source : string
-
Source identifier
Return values
boolregister()
Register a renderer for a given source (e.g. 'Authorizations', 'Awards').
public
static register(string $source, ApprovalContextRendererInterface $renderer) : void
Parameters
- $source : string
-
Plugin or module identifier
- $renderer : ApprovalContextRendererInterface
-
Renderer instance
render()
Render approval context for a workflow instance.
public
static render(WorkflowInstance $instance) : ApprovalContext
Returns the result from the first renderer that can handle the instance, or a generic fallback context.
Parameters
- $instance : WorkflowInstance
-
Workflow instance
Return values
ApprovalContextunregister()
Remove the renderer for a specific source.
public
static unregister(string $source) : void
Parameters
- $source : string
-
Source identifier
contextCacheKey()
Build a request-local cache key for persisted workflow instances.
private
static contextCacheKey(WorkflowInstance $instance) : string|null
Parameters
- $instance : WorkflowInstance
-
Workflow instance.
Return values
string|nullensureInitialized()
Ensure the registry is initialized.
private
static ensureInitialized() : void