Skip to content

Commit 13f2b51

Browse files
Mike van den Hoekmvdhoek1
authored andcommitted
feat: user object model class
1 parent f86e018 commit 13f2b51

12 files changed

Lines changed: 849 additions & 375 deletions

File tree

.php-cs-fixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
'binary_operator_spaces' => [
2727
'default' => 'single_space',
2828
'operators' => [
29-
'=>' => null,
29+
'=>' => 'single_space',
3030
'|' => 'no_space',
3131
],
3232
],

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ Important:
6969

7070
The source code is made available under the [EUPL 1.2 license](https://github.com/OpenWebconcept/plugin-prefill-gravity-forms/blob/main/LICENSE.md). Some of the dependencies are licensed differently, with the BSD or MIT license, for example.
7171

72+
## User model
73+
74+
The `UserModel` provides a simple way to access BRP (Basisregistratie Personen) data that has been retrieved after a valid DigiD login.
75+
It automatically detects which data supplier is configured (in the add-on settings), loads the correct controller, and exposes a small set of helper methods for use in templates or form-prefill logic.
76+
77+
Before accessing any user attributes, always check whether the user is authenticated using DigiD.
78+
79+
### Usage
80+
81+
```php
82+
$user = new \OWC\PrefillGravityForms\Models\UserModel();
83+
84+
if ( $user->isLoggedIn() ) {
85+
$bsn = $user->bsn();
86+
$age = $user->age();
87+
}
88+
```
89+
90+
This model does not handle authentication itself, it only exposes data retrieved by the underlying BRP supplier controller.
91+
If a controller fails to load (e.g., misconfiguration or missing supplier), the model gracefully returns default values.
92+
93+
To use this model, make sure it is enabled in the settings available at '/wp-admin/admin.php?page=gf_settings&subview=owc-gravityforms-iconnect'.
94+
Otherwise, the object will be instantiated but will not contain any data.
95+
7296
## Logging
7397

7498
Enable logging to monitor errors during communication with the BRP suppliers.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121
],
2222
"require": {
23+
"monolog/monolog": "^3.0",
2324
"php": "^8.0",
2425
"php-di/php-di": "^7.0",
2526
"owc/idp-userdata": "^1.0"

0 commit comments

Comments
 (0)