Hi everyone,
Recently came back to using symfony after an extended absence and
basically re-learned everything. Love the framework - huge fan. I have
a bit of a problem...
Basically, I have a module and I've added a new action to it that
returns nothing but XML. I set the content-type to XML and set the
response content to nothing but the XML text. here's the action:
public function executeCalendar(sfWebRequest $request)
{
// Grab parameters and parse, to determine which user and/or date
range to send for data request.
//$params = $request->extractParameters(array("user","date"));
if(sfContext::getInstance()->getRequest()->hasAttribute('date'))
{
$dateString =
sfContext::getInstance()->getRequest()->getAttribute
('date');
$this->displayDate = new CFLBDate(-1,-1,-1,$dateString);
}
else
{
$dateInfo = getdate();
$this->displayDate = new CFLBDate($dateInfo['year'], $dateInfo
['mon'], $dateInfo['mday']);
}
$this->user = sfContext::getInstance()->getRequest()->getAttribute
('user');
$this->user = "1"; // For testing - using known instance of user with
ID 1, just to make sure it works.
$theLogbookController = LogbookController::singleton();
$logbookCalendar = $theLogbookController->getCalendarDetails($this-
>user, $this->displayDate);
$XML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$XML .= "<root fields=\"startdate|enddate|location|description|type\">
\n";
foreach ($logbookCalendar->calendarEntries as $row => $calendarInfo)
{
$XML .= "<e a=\"".$calendarInfo->date."\" ";
$XML .= "e=\"event\" ";
$XML .=
"f=\"".(strlen($calendarInfo->workoutName)>0?$calendarInfo-
>workoutName.": ":"").(strlen($calendarInfo->workoutDescription)>0?
$calendarInfo->workoutDescription:"")."\">\n";
foreach ($calendarInfo->achievements as $achievement)
{
$XML .= "<achievement icon=\"".str_replace(" ", "",
$achievement-
>name).".png\"></achievement>\n";
}
$XML .= "</e>\n";
}
$XML .= "</root>";
$response = $this->getResponse();
$response->setHttpheader('Content-type', 'text/xml');
$response->setContent($XML);
return sfView::NONE;
}
Hopefully that's legible.
It is imperative for the UI components I am using that the response be
pure, valid XML. As far as I can tell, this function does this.
So here's my problem: it seems to me that symfony adds an extra line
break right BEFORE the content. The actual content is perfect, but
because there is an extra line break at the start of the response
content, the XML does not validate and thus my UI components. Searched
the groups and the great Google oracle, alas no results.
If anyone has any ideas, please let me know. Otherwise going to start
jumping into sf code :o
BY THE WAY, using sf 1.2.8
Thanks in advance for any advice/info/help!
--
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en.