Repository navigation
feat: add number of residents and BRP v2 address getters to UserModel - #40
richardkorthuis wants to merge 3 commits into
Conversation
richardkorthuis
commented
Nov 17, 2026
- UserModel: zipcode(), houseNumber() and houseLetter() now read BRP v2 (verblijfplaats.verblijfadres.*) with v1 fallback; new street(), city(), houseNumberAddition(), nummeraanduidingIdentificatie() and residentsCount()
- PostController::countResidents(): BRP search ZoekMetNummeraanduidingIdentificatie with fields [burgerservicenummer]; only the count is cached (encrypted, own transient key), persons are discarded; falls back to the general goal binding and processing from the settings
- BaseController::executeCurlRequest(): cURL request without BSN-bound caching that never puts the raw response in exception messages
- Mappable field "Aantal bewoners" (aantalBewoners) for v2 suppliers in the Gravity Forms field mapping and the Personal Data Row block; only requested when a form field is mapped to it
- Unit tests for UserModel, residents count, PersonalDataService and form prefill
- UserModel: zipcode(), houseNumber() and houseLetter() now read BRP v2 (verblijfplaats.verblijfadres.*) with v1 fallback; new street(), city(), houseNumberAddition(), nummeraanduidingIdentificatie() and residentsCount() - PostController::countResidents(): BRP search ZoekMetNummeraanduidingIdentificatie with fields [burgerservicenummer]; only the count is cached (encrypted, own transient key), persons are discarded; falls back to the general goal binding and processing from the settings - BaseController::executeCurlRequest(): cURL request without BSN-bound caching that never puts the raw response in exception messages - Mappable field "Aantal bewoners" (aantalBewoners) for v2 suppliers in the Gravity Forms field mapping and the Personal Data Row block; only requested when a form field is mapped to it - Unit tests for UserModel, residents count, PersonalDataService and form prefill
There was a problem hiding this comment.
🟡 Changes recommended
Address-only caching can bypass goal-binding authorization by reusing counts across bindings, while cold person lookups fail to apply the general goal binding when no explicit binding is set.
2 open issues
1 file not reviewed
build/personal-data-table/personal-data-row/index.js: Generated file
What changed in this PR
This PR extends the plugin’s BRP v2 support with address getters and resident counts, available through UserModel, Gravity Forms mappings and Personal Data Row blocks.
Changes:
- Adds BRP v2 address getters with v1 fallback.
- Adds on-demand resident-count searches with encrypted count-only caching and response-safe request errors.
- Updates mapping options, built assets, documentation and unit tests.
| File | Description |
|---|---|
| tests/Unit/Services/PersonalDataServiceTest.php | Tests resident-count retrieval and existing field behavior. |
| tests/Unit/Models/UserModelTest.php | Tests address getters and resident-count behavior. |
| tests/Unit/Fixtures/brp-v2-zoek-nummeraanduiding.json | Adds a resident-search response fixture. |
| tests/Unit/Fixtures/brp-v2-raadpleeg-persoon.json | Adds a BRP v2 person fixture. |
| tests/Unit/Fixtures/brp-v1-ingeschrevenpersoon.json | Adds a v1 compatibility fixture. |
| tests/Unit/bootstrap.php | Defines the cache-duration constant for tests. |
| tests/Unit/Abstracts/PostControllerResidentsCountTest.php | Tests count requests, caching and failures. |
| tests/Unit/Abstracts/PostControllerAddResidentsCountTest.php | Tests mapped-field counting and prefill. |
| tests/Stubs/WordPress/GF_Field.php | Adds a minimal Gravity Forms field stub. |
| src/PrefillGravityForms/Services/PersonalDataService.php | Supports the virtual resident-count field. |
| src/PrefillGravityForms/Models/UserModel.php | Adds address getters and memoized resident counts. |
| src/PrefillGravityForms/Controllers/PinkRoccadeV2Controller.php | Integrates counts into mapped form responses. |
| src/PrefillGravityForms/Controllers/EnableUV2Controller.php | Integrates counts into mapped form responses. |
| src/PrefillGravityForms/Controllers/BaseController.php | Adds uncached requests with response-safe exceptions. |
| src/PrefillGravityForms/Abstracts/PostController.php | Implements resident searches and count-only caching. |
| resources/views/partials/gf-field-options-pink-roccade-v2.php | Adds the resident-count mapping option. |
| resources/views/partials/gf-field-options-enable-u-v2.php | Adds the resident-count mapping option. |
| resources/js/blocks/personal-data-table/personal-data-row/config/personalDataOptions.js | Adds the resident-count block option. |
| README.md | Documents getters, counts and mapping limitations. |
| CHANGELOG.md | Records the new features and address fixes. |
| build/personal-data-table/personal-data-row/index.js | Updates the compiled block options. |
| build/personal-data-table/personal-data-row/index.asset.php | Updates the block asset version. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
mvdhoek1
left a comment
There was a problem hiding this comment.
Ziet er goed uit, vergeet niet om het .pot bestand bij te werken. En graag nog @since NEXT toevoegen aan nieuwe methods.
| $this->applyCurlSSLOptions($curl); | ||
|
|
||
| $output = curl_exec($curl); | ||
| $errorNumber = curl_errno($curl); |
There was a problem hiding this comment.
Willen we niet een error message gebruiken voor de logging?
$errorMessage = curl_error($curl);
if (0 !== $errorNumber || ! is_string($output)) {
throw new Exception(sprintf('cURL request failed [%d]: %s', $errorNumber, $errorMessage), 500);
}| } | ||
|
|
||
| if ('' === $goalBinding) { | ||
| $goalBinding = \OWC\PrefillGravityForms\GravityForms\GravityFormsSettings::make()->getGoalBinding(); |
There was a problem hiding this comment.
Wellicht:
use OWC\PrefillGravityForms\GravityForms\GravityFormsSettings;
En dan:
$goalBinding = GravityFormsSettings::make()->getGoalBinding();

