Authorizes intents for both presentation and execution.
Intent authorization is a continuous filter, not a single checkpoint.
The same authorization rules apply in two distinct phases:
Discovery / Presentation
Invocation / Execution
This interface intentionally unifies both concerns to ensure:
CmdK / Navigation: -> authorize() decides whether a discovered intent may be offered.
IntentDispatcher: -> authorize() is called for the selected intent before handling.
One method answers both phases, by design: what is offered and what may run
cannot then diverge. (A list-level filter() was considered and not built —
callers filter with authorize().)
final class OpenReportIntentAuthorizer implements IntentAuthorizerInterface
{
public function authorize(
IntentInterface $intent,
SdkContext $context
): bool {
return $context->user()->can('viewReports');
}
}
| Methods | ||
|---|---|---|
public
|
authorize(IntentInterface $intent, SdkContext $context): bool
|
# |