ZF-1024: Response - named segments

Description

I suggest considering the possibility of supporting named body segments in the Response object. This would allow manipulation of specific physical segments in the response, such as prepending a doctype based on the results of an action, then inserting or appending an inline CSS

For example:


// insert a "header" segment before the "body" segment
$response->insert('header', 'body', $view->render($header));
// insert a "doctype" segment at the beginning of the "response"
$response->prepend('doctype', 'header', $doctype));
// append content to the "header" segment
$response->appendBody('header', $view->render('metatags.tpl.php'));

There are many possible variations of inserting, removing, prepending, appending, and setting segments in this ordered sequence data structure. Hopefully this Jira issue will prove useful to collect feedback and ideas into a single location for easy reviewing.

An obvious alternative exists using getBody() and setBody(), where all management of "segments" is done in userland. However, the current implementation of getBody() does not provide access to the {{$_body}} array, and various inefficiencies arise as a result. Adding support for getting and setting {{$_body}} as an array yields another alternative.

Comments

This is a very cool idea. I'm not too happy with my current header/footer solution and this sounds like a great improvement and something I could really make use of.

Gets my vote.

I needed this years ago in order to properly prioritize segments for portal-like websites, where "view panes" were dynamically selected and organized based on user preferences and other input. Javascript, CSS, and the DOM sometimes requires careful organization of "parts".

I see these changes are in th svn trunk now. Good work guys. can't wait to start playing around with it.

Assign Zend_Controller issues to Matthew.

I believe this issue is resolved and the committed patch works as asked for :)

I can confirm that ;)