I am looking to extend FOF Masquerade's bio functionality and create an API endpoint that only returns a single field value as plain text.
I can use the following code to serialize my custom controller with payload, but that assumes JSON output.
(new Extend\ApiController(MyController::class))
->addInclude('bioFields.field')
->addInclude('masqueradeAnswers'),
To return plain text I changed MyController
to implement RequestHandlerInterface
, and I believe this skips the post-controller serialization that augments those includes.
How can I modify my $User object within the controller to access these extended attributes?
public function handle(ServerRequestInterface $request): ResponseInterface
{
$slug = Arr::get($request->getQueryParams(), 'slug');
$user = $this->users->findOrFailByUsername($slug);
//this does not work - just trying to dump user object for inspection. But it does not include the `includes` from my extend.
return new HtmlResponse(print_r($user));
}
```