*/ class WebhooksController extends AbstractStationApiCrudController { protected string $entityClass = Entity\StationWebhook::class; protected string $resourceRouteName = 'api:stations:webhook'; protected function viewRecord(object $record, ServerRequest $request): mixed { if (!($record instanceof Entity\StationWebhook)) { throw new InvalidArgumentException(sprintf('Record must be an instance of %s.', $this->entityClass)); } $return = $this->toArray($record); $isInternal = ('true' === $request->getParam('internal', 'false')); $router = $request->getRouter(); $return['links'] = [ 'self' => (string)$router->fromHere( route_name: $this->resourceRouteName, route_params: ['id' => $record->getIdRequired()], absolute: !$isInternal ), 'toggle' => (string)$router->fromHere( route_name: 'api:stations:webhook:toggle', route_params: ['id' => $record->getIdRequired()], absolute: !$isInternal ), 'test' => (string)$router->fromHere( route_name: 'api:stations:webhook:test', route_params: ['id' => $record->getIdRequired()], absolute: !$isInternal ), ]; return $return; } }