API Transformer - evansims/openfga-php GitHub Wiki
OpenFGA DSL Transformer implementation for authorization model conversions. This class provides complete implementation for converting between OpenFGA's Domain Specific Language (DSL) format and structured authorization model objects. It supports complex relationship definitions including unions, intersections, exclusions, and computed usersets with proper precedence handling. The transformer parses DSL syntax including: - Type definitions with relations - Direct user assignments [user, organization#member] - Computed usersets (owner, administrator) - Tuple-to-userset relations (owner from parent) - Boolean operations (and, or, but not) - Parenthetical grouping for precedence
Table of Contents
OpenFGA
- TransformerInterface (interface)
Implements TransformerInterface
public function fromDsl(string $dsl, SchemaValidatorInterface $validator): AuthorizationModelInterface
Parse a DSL string into an authorization model. This method converts a human-readable DSL (Domain Specific Language) string into a structured authorization model object that can be used with the OpenFGA API. The DSL provides an intuitive way to define authorization relationships and permissions using familiar syntax.
Name | Type | Description |
---|---|---|
$dsl |
string |
The DSL string containing the authorization model definition |
$validator |
SchemaValidatorInterface |
Schema validator for validating the parsed model structure |
AuthorizationModelInterface
— The parsed authorization model ready for API operations
Implements TransformerInterface
public function toDsl(AuthorizationModelInterface $model): string
Convert an authorization model to its DSL string representation. This method transforms a structured authorization model object back into its human-readable DSL format, making it easy to review, edit, or share authorization model definitions. The output can be saved to files, version controlled, or used for documentation purposes.
Name | Type | Description |
---|---|---|
$model |
AuthorizationModelInterface |
The authorization model to convert to DSL format |
string
— The DSL string representation of the authorization model