This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/lib/Rails/ActionController/Response/Xml.php

29 lines
789 B
PHP
Raw Normal View History

2013-10-02 18:14:53 +02:00
<?php
namespace Rails\ActionController\Response;
class Xml extends Base
{
private $_xml;
public function _render_view()
{
$el = array_shift($this->_params);
if ($el instanceof \Rails\ActiveRecord\Collection) {
$this->_xml = new \Rails\ActionView\Xml();
$root = $this->_params['root'];
$this->_xml->instruct();
$this->_xml->$root([], function() use ($el) {
foreach ($el as $model) {
$model->toXml(['builder' => $this->_xml, 'skip_instruct' => true]);
}
});
} else
$this->_xml = new \Rails\Xml\Xml($el, $this->_params);
}
public function _print_view()
{
return $this->_xml->output();
}
}