common-gateway/sim-xml-to-zgw-bundle
Install the Bundle
composer require common-gateway/sim-xml-to-zgw-bundle:dev-main
php bin/console commongateway:install common-gateway/sim-xml-to-zgw-bundle
Plugins tab.Locate Core Configuration
config/packages/common_gateway_sim_xml_to_zgw.yaml (auto-generated) for default settings.config/bundles.php to ensure the bundle is enabled.First Translation Use Case
use CommonGateway\SimXMLToZGWBundle\Service\SimXMLConverter;
$converter = $this->container->get(SimXMLConverter::class);
$zgwObject = $converter->convert($simXmlString);
ZGW\Message\ZGWMessageInterface).SOAP/SimXML Ingestion
public function handle(Request $request, Closure $next): Response
{
if ($request->isXml()) {
$simXml = $request->getContent();
$zgwObject = $this->simXMLConverter->convert($simXml);
// Proceed with ZGW logic...
}
return $next($request);
}
Schema Validation
$validator = $this->container->get(SimXMLValidator::class);
$errors = $validator->validate($simXml);
if ($errors->count() > 0) {
throw new \RuntimeException('Invalid SimXML: ' . $errors->get(0)->getMessage());
}
Dynamic Plugin Extension
# config/packages/common_gateway_sim_xml_to_zgw.yaml
common_gateway_sim_xml_to_zgw:
custom_mappers:
- App\Mapper\CustomSimXMLMapper
CommonGateway\SimXMLToZGWBundle\Mapper\SimXMLMapperInterface for domain-specific logic.Event-Driven Processing
simxml.converted events to react to translations:
use CommonGateway\SimXMLToZGWBundle\Event\SimXMLConvertedEvent;
$eventDispatcher->addListener(SimXMLConvertedEvent::class, function (SimXMLConvertedEvent $event) {
// Post-process $event->getZGWObject()
});
SimXMLConverter and related services in controllers/services.$this->logger->info('SimXML converted to ZGW', ['sim_xml' => $simXml, 'zgw_object' => $zgwObject]);
SimXMLConverter in PHPUnit:
$this->mockBuilder->disableOriginalConstructor()
->getMockBuilder(SimXMLConverter::class)
->disableOriginalConstructor()
->onlyMethods(['convert'])
->getMock();
Schema Mismatches
SchemaLoader to debug:
$schema = $this->schemaLoader->load('zgw_schema.xsd');
$validator->validateAgainstSchema($simXml, $schema);
SimXMLConverter to handle custom mappings or pre-process XML.Circular Dependencies
SimXMLConverter into services that are also autowired as bundle dependencies (e.g., mappers). Use constructor injection sparingly.Admin UI Discovery Issues
composer.json includes "type": "symfony-bundle".php bin/console cache:clear.Namespace Collisions
ZGW\ namespace for output objects. Override with:
common_gateway_sim_xml_to_zgw:
zgw_namespace: App\ZGW\
Enable Verbose Logging
php bin/console debug:config common_gateway_sim_xml_to_zgw
Set debug: true in config to log raw SimXML/ZGW payloads.
Dump Converter State
$converter->setDebug(true); // Temporarily enable debug mode
Custom Mappers
SimXMLMapperInterface:
class CustomFieldMapper implements SimXMLMapperInterface {
public function map(array $simXmlData): array {
return [
'custom_field' => $simXmlData['legacy_field'] ?? null,
];
}
}
common_gateway_sim_xml_to_zgw:
custom_mappers:
- App\CustomFieldMapper
Post-Conversion Hooks
simxml.post_convert event to modify ZGW objects:
$eventDispatcher->addListener(SimXMLPostConvertEvent::class, function (SimXMLPostConvertEvent $event) {
$event->setZGWObject($this->enrichZGWObject($event->getZGWObject()));
});
Schema Customization
schema_path config:
common_gateway_sim_xml_to_zgw:
schema_path: '%kernel.project_dir%/config/zgw_schemas'
common_gateway_sim_xml_to_zgw:
schema_cache_enabled: true
SimXMLBatchConverter:
$batchConverter = $this->container->get(SimXMLBatchConverter::class);
$results = $batchConverter->convertBatch([$simXml1, $simXml2]);
How can I help you explore Laravel packages today?