Download the PHP package innobraingmbh/onoffice-structure without Composer
On this page you can find all versions of the php package innobraingmbh/onoffice-structure. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innobraingmbh/onoffice-structure
More information about innobraingmbh/onoffice-structure
Files in innobraingmbh/onoffice-structure
Package onoffice-structure
Short Description Package to extract the enterprise configuration
License MIT
Homepage https://github.com/innobraingmbh/onoffice-structure
Informations about the package onoffice-structure
onOffice Structure Extractor for Laravel
Extract and work with the onOffice enterprise field configuration (Modul- und Feldkonfiguration) in Laravel. The package fetches configurations via innobrain/laravel-onoffice-adapter, transforms them into readonly DTOs, and converts them into various output formats using a strategy pattern.
Features
- Fetch field configurations for all onOffice modules (Address, Estate, AgentsLog, Calendar, Email, File, News, Intranet, Project, Task, User)
- Readonly DTOs for Modules, Fields, Permitted Values, Dependencies, and Filters
- Convert to arrays, Laravel validation rules, or JSON Schema
- Filter fields by configuration-based conditions with a fluent builder
- Sanitize input data against field definitions and permitted values
- Multi-language support (German, English, French, Spanish, Italian, Croatian)
- Extensible converter strategy pattern for custom output formats
Installation
You can optionally publish the configuration file:
Usage
Fetching Structure Data
Use the Structure facade or inject Innobrain\Structure\Services\Structure:
Filtering Fields
Fields can have filter configurations that determine their visibility based on other field values. Use the fluent FieldFilterBuilder to narrow down fields:
Writable Fields and Dependent Permitted Values
Hints, dividing lines and compound fields cannot be written to the API. FieldCollection::writable() drops them:
Some permitted values depend on the value of a parent field. In the estate module the objekttyp values depend on objektart. Field::withPermittedValuesFor() narrows a field to the permitted values allowed for a parent value:
Looking Up Fields and Permitted Values
The API accepts field keys in any casing, so field lookups fall back to a case-insensitive match. Module keys are fixed, so module() matches exactly:
Field resolves permitted values by key or label, which is handy for user or AI input:
Sanitizing Input Data
sanitize() removes keys that don't match known fields and values that are not permitted. Items of a multi-select array are removed individually:
violations() reports what sanitize() would drop, as FieldViolation DTOs with a ViolationReason:
Caching
The DTOs serialize cleanly, so a ModulesCollection can be cached as-is. If your cache store restricts unserializable classes, allow the package's classes in config/cache.php:
Converting Data
Module, Field and ModulesCollection implement Convertible and can be transformed using a ConvertStrategy.
Array Conversion
Laravel Validation Rules
Module conversions for Laravel rules and JSON Schema only include writable fields (FieldCollection::writable()). Hints and dividing lines carry no data, and compound fields such as Plz-Ort are set through their individual fields, so they are left out. Converting such a field directly still works.
JSON Schema
Writing a Custom Converter
Implement ConvertStrategy with convertField and convertModule:
Testing Your Application
Structure::fake() (or FieldConfiguration::fake()) replaces the API call with canned modules for the rest of the test. The factories build DTOs without spelling out every constructor argument:
The fake narrows to the requested modules and still throws for unknown module keys. The same modules are returned for every language.
Both factories are Conditionable, so ->when($condition, fn ($field) => $field->default('haus')) works as on query builders.
DTOs
All DTOs are readonly. Field only requires key, label and type; the other properties default to null or an empty collection.
| DTO | Key Properties |
|---|---|
Module |
key (FieldConfigurationModule), label, fields (FieldCollection) |
Field |
key, label, type (FieldType), length, permittedValues, default, filters, dependencies, compoundFields, fieldMeasureFormat (FieldMeasureFormat) |
PermittedValue |
key, label |
FieldDependency |
permittedValueKey, parentFieldValue (the permitted value is only available when the parent field holds that value, e.g. objekttyp => objektart) |
FieldFilter |
name, config |
FieldViolation |
fieldKey, value, reason (ViolationReason) |
Testing
Changelog
Please see CHANGELOG.md for more information on what has changed recently.
Contributing
Contributions are welcome! Please open an issue or pull request. For bug reports, use the Bug Report Template.
Security Vulnerabilities
If you discover a security vulnerability, please send an e-mail to Konstantin Auffinger via the email address in composer.json. All security vulnerabilities will be promptly addressed.
Credits
- Konstantin Auffinger
- All Contributors
Built with Spatie's Laravel Package Tools.
License
The MIT License (MIT). Please see composer.json for more information.
All versions of onoffice-structure with dependencies
illuminate/contracts Version ^12.53|^13.0
innobrain/laravel-onoffice-adapter Version ^1.10|^2.0
spatie/laravel-package-tools Version ^1.16