Closed ghost closed 6 years ago
Another ugly approach that avoids the dummy response would be to assign the data to template vars and then include some php code in the template to do the formatting. Not recommended and probably even worse. https://wiki.phpbb.com/Tutorial.Template_syntax#PHP
The following works for me, and fixes the rendering in web browsers (because of the content type)
$yaml = "Player:\n";
$yaml .= "\tFingerprint: " . $data['fingerprint'] . "\n";
$yaml .= "\tPublicKey: " . base64_encode($data['public_key']) . "\n";
$yaml .= "\tKeyRevoked: " . ($data['revoked'] ? 'true' : 'false') . "\n";
$yaml .= "\tProfileID: " . $data['user_id'] . "\n";
$yaml .= "\tProfileName: " . $data['username'] . "\n";
$yaml .= "\tProfileRank: Registered User\n";
$yaml .= "\tBadges:\n";
if ($badges)
{
$i = 0;
foreach ($badges as $badge)
{
$yaml .= "\t\tBadge@$i:\n";
$yaml .= "\t\t\tLabel: " . $badge['badge_label'] . "\n";
$yaml .= "\t\t\tIcon16: " . generate_board_url () . '/' . $this->config['badges_path'] . '/' . $badge['badge_icon_16'] . "\n";
$i++;
}
}
$response = new Response($yaml);
$response->headers->set('Content-Type', 'Content-type: text/plain; charset=utf-8');
return $response;
Works as promised so closing.
Currently uses a dummy response while using echo to output data because the Symfony response will include header information. This information needs to be excluded to be compatible to game integration.