So I have figured everything out. Ultimately, I should probably make a demo repo to share. Short version:
- for FOSRest in my config.yml, set hal+json and hal+xml to true and defined mime types.
- in my services.yml (inside my symfony bundle), defined my own handler service with the fos_rest.view_handler.default as a parent and called registerHandler twice, once for hal+json and againf or hal+xml
- extended the HATEOAS json and xml event subscribers. Changed getsubscribedEvents() to return hal+json(xml) and in my config.yml I set the hateoas.event_subscriber.json(xml).class parameter to point to my extended versions.
- I also had to declare JMS serializer services to handle hal+json(xml). I just used the default json and xml visitors in the service definition. Just changed for the format (again hal+json(xml))
If you do all of this, the following format listener will work:
format_listener:
rules:
- { path: '^/', priorities: ['hal+json', 'hal+xml', 'json', 'xml'], fallback_format: hal+json, prefer_extension: true }
This approach teaches both FOS Rest and JMS serializer to treat the HAL formats as unique content types and triggers the HATEOAS bundle to only work for hal content types which leaves vanilla json and xml alone. Again, I should probably set up a demo repo to illustrate everything. If anybody has any questions before I get around to that, please feel free to ask!