common-gateway/huwelijk-vrijbrp-bundle
Install via Composer
composer require common-gateway/huwelijk-vrijbrp-bundle
Ensure your project uses Common Gateway CoreBundle (required dependency).
Enable the Bundle
Add to config/bundles.php:
return [
// ...
CommonGateway\HuwelijkVrijBRPBundle\HuwelijkVrijBRPBundle::class => ['all' => true],
];
Database Migrations Run migrations to create required tables:
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
First Use Case: Register a Marriage Use the provided API or CLI command to create a marriage record:
php bin/console app:huwelijk:create --partner1=123 --partner2=456 --date=2024-01-01
Verify in the database (huwelijk table) or via the admin interface (if configured).
config/packages/huwelijk_vrijbrp.yaml (if auto-generated).src/Entity/Huwelijk.php (core model).src/Command/ (CLI tools for testing).src/Service/ (business logic, e.g., HuwelijkService).Marriage Registration
HuwelijkController or create a custom endpoint:
// src/Controller/CustomHuwelijkController.php
use CommonGateway\HuwelijkVrijBRPBundle\Controller\HuwelijkController;
class CustomHuwelijkController extends HuwelijkController {
public function customAction(Request $request) {
$this->huwelijkService->registerMarriage($request->request->all());
return new JsonResponse(['status' => 'success']);
}
}
HuwelijkType (Symfony form) in your templates:
{{ form_start(form) }}
{{ form_row(form.partner1) }}
{{ form_row(form.partner2) }}
{{ form_row(form.date) }}
{{ form_end(form) }}
Data Synchronization with VrijBRP
HuwelijkSyncService to push/pull data to/from VrijBRP:
$syncService = $this->container->get('huwelijk_vrijbrp.sync_service');
$syncService->syncMarriage($huwelijkEntity);
Event Listeners
HuwelijkEvents (e.g., HuwelijkCreatedEvent) for post-registration logic:
// src/EventListener/HuwelijkListener.php
use CommonGateway\HuwelijkVrijBRPBundle\Event\HuwelijkEvents;
class HuwelijkListener {
public function onHuwelijkCreated(HuwelijkCreatedEvent $event) {
// Send notification, log, etc.
}
}
Register in services.yaml:
services:
App\EventListener\HuwelijkListener:
tags:
- { name: kernel.event_listener, event: huwelijk.created, method: onHuwelijkCreated }
Custom Fields: Extend Huwelijk entity to add fields (e.g., witnesses, location):
// src/Entity/Huwelijk.php
/**
* @ORM\Column(type="string", nullable=true)
*/
private $location;
Update migrations and forms accordingly.
Validation: Override validation rules in HuwelijkType:
// src/Form/HuwelijkType.php
$builder->add('date', DateType::class, [
'constraints' => [
new NotBlank(),
new Callback([$this, 'validateDate']),
],
]);
API Integration: Use Symfony’s Serializer to expose marriage data:
// src/Serializer/HuwelijkNormalizer.php
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class HuwelijkNormalizer implements NormalizerInterface {
public function normalize($object, $format = null, array $context = []) {
return [
'id' => $object->getId(),
'partners' => [$object->getPartner1(), $object->getPartner2()],
'date' => $object->getDate()->format('Y-m-d'),
];
}
}
Testing: Use HuwelijkTestCase (if provided) or mock the HuwelijkService:
$this->container->get('huwelijk_service')->method('registerMarriage')
->willReturn($huwelijkEntity);
Missing Dependencies
common-gateway/core-bundle and vrijbrp/vrijbrp are installed. The bundle assumes these are present.composer require common-gateway/core-bundle vrijbrp/vrijbrp.Database Schema Mismatches
huwelijk tables.src/Resources/migrations/ and adjust or drop tables before re-running migrations.VrijBRP API Credentials
huwelijk_vrijbrp.yaml:
huwelijk_vrijbrp:
vrijbrp:
api_url: "https://vrijbrp.example.com/api"
client_id: "%env(VRIJBRP_CLIENT_ID)%"
client_secret: "%env(VRIJBRP_CLIENT_SECRET)%"
Event Dispatching
huwelijk.created may not fire if the bundle isn’t fully initialized.CoreBundle in bundles.php.Partner Validation
HuwelijkType:
$builder->add('partner1', EntityType::class, [
'class' => 'App\Entity\Persoon',
'constraints' => [new ValidBSN()],
]);
Enable Debug Mode
Add to .env:
APP_DEBUG=1
HUWELIJK_VRIJBRP_DEBUG=1
This logs sync operations and API calls.
Log Sync Errors
Override HuwelijkSyncService to log failures:
public function syncMarriage(Huwelijk $huwelijk) {
try {
// Sync logic...
} catch (\Exception $e) {
$this->logger->error('Sync failed for huwelijk ID ' . $huwelijk->getId(), ['error' => $e->getMessage()]);
throw $e;
}
}
Check API Responses
Use HUWELIJK_VRIJBRP_API_DEBUG=1 to log raw VrijBRP API responses.
Custom Marriage Types
Extend Huwelijk entity to support different marriage types (e.g., civil, religious):
// src/Entity/Huwelijk.php
public const TYPE_CIVIL = 'civil';
public const TYPE_RELIGIOUS = 'religious';
/**
* @ORM\Column(type="string")
*/
private $type;
Webhooks
Add a HuwelijkWebhookService to notify external systems:
// src/Service/HuwelijkWebhookService.php
public function sendCreatedWebhook(Huwelijk $huwelijk) {
$client = new \GuzzleHttp\Client();
$client->post('https://external-system.com/webhook', [
'json' => ['huwelijk' => $huwelijk->getId()],
]);
}
Batch Processing
Use Symfony’s Messenger component to process marriages asynchronously:
// src/Message/HuwelijkSyncMessage.php
class HuwelijkSyncMessage {
public function __construct(private Huwelijk $huwelijk) {}
}
// src/MessageHandler/HuwelijkSyncHandler.php
class HuwelijkSyncHandler {
public function __invoke(HuwelijkSyncMessage $message
How can I help you explore Laravel packages today?