API Models Condition - evansims/openfga-php GitHub Wiki
Represents an ABAC (Attribute-Based Access Control) condition in your authorization model. A Condition defines a logical expression that must evaluate to true for authorization to be granted. It includes the expression code, parameter definitions, and optional metadata. Conditions enable context-aware authorization decisions based on attributes of users, resources, and environment. Use this when implementing fine-grained access control that depends on runtime attributes and contextual information.
Table of Contents
OpenFGA\Models
ConditionInterfaceJsonSerializableModelInterface
- ConditionInterface (interface)
- Conditions (collection)
| Name | Value | Description |
|---|---|---|
OPENAPI_MODEL |
Condition |
public function getContext(): ?arrayGet the context for the condition. This provides additional runtime data that can be used by the condition's expression for dynamic evaluation.
array | null — the context data, or null if not provided
public function getExpression(): stringGet the condition expression. This returns the logical expression that defines when this condition evaluates to true. The expression can reference parameters and context data to enable dynamic authorization decisions based on runtime information.
string — The condition expression defining the evaluation logic
public function getMetadata(): ?OpenFGA\Models\ConditionMetadataInterfaceGet metadata about the condition definition. This provides additional information about where the condition was defined and how it should be processed, which is useful for tooling and debugging.
ConditionMetadataInterface | null — The condition metadata, or null if not provided
public function getName(): stringGet the name of the condition. This is a unique identifier for the condition within the authorization model, allowing it to be referenced from type definitions and other parts of the model.
string — The unique name identifying this condition
public function getParameters(): ?OpenFGA\Models\Collections\ConditionParametersInterfaceGet the parameters available to the condition expression. These parameters define the typed inputs that can be used within the condition expression, enabling dynamic evaluation based on contextual data provided during authorization checks.
ConditionParametersInterface | null — The condition parameters, or null if the condition uses no parameters
public function jsonSerialize(): array<string, mixed>Serialize the condition for JSON encoding. This method prepares the condition data for API requests or storage, ensuring all components are properly formatted according to the OpenFGA API specification.
array<string, mixed> — The serialized condition data
Implements Models\ConditionInterface
public function schema(): SchemaInterfaceGet the schema definition for this model. This method returns the schema that defines the structure, validation rules, and serialization behavior for this model class. The schema is used for data validation, transformation, and ensuring consistency across API operations with the OpenFGA service. Each model's schema defines: - Required and optional properties - Data types and format constraints - Nested object relationships - Validation rules and business logic constraints The schema system enables the SDK to automatically validate incoming data, transform between different representations, and ensure compliance with the OpenFGA API specification.
SchemaInterface — The schema definition containing validation rules and property specifications for this model