merged branch excelwebzone/dev (PR #2706)
Commits -------8710a13
Added example to the change log filec9a2b49
Fixed xml encoder test script, and group `item` tags into an arraya0561e5
Replaced `item` with `*item` when parsing XML string Discussion ---------- Replaced `item` with `*item` when parsing XML string --------------------------------------------------------------------------- by fabpot at 2011/11/23 22:14:12 -0800 Tests do not pass: 1) Symfony\Tests\Component\Serializer\Encoder\XmlEncoderTest::testDecode Failed asserting that two arrays are equal. --- Expected +++ Actual @@ @@ 'key2' => 'val' - 'A B' => 'bar' 'Barry' => Array (...) + 'item' => Array (...) ) 'qux' => '1' ) .../tests/Symfony/Tests/Component/Serializer/Encoder/XmlEncoderTest.php:173 --------------------------------------------------------------------------- by fabpot at 2011/11/24 22:57:37 -0800 I don't understand the patch anymore. I don't see any use of `*item` in the code. --------------------------------------------------------------------------- by excelwebzone at 2011/11/24 23:04:07 -0800 I run some testing and you can't use '*item' XML parser reject it. So I modified it to convert it to an array.. Look at the test script change --------------------------------------------------------------------------- by fabpot at 2011/11/24 23:13:30 -0800 So, you probably need to change the CHANGELOG as well? You should add an example which shows a before/after example. --------------------------------------------------------------------------- by excelwebzone at 2011/11/24 23:15:51 -0800 Yes, forgot to change that.. --------------------------------------------------------------------------- by fabpot at 2011/11/25 01:27:42 -0800 ping @Seldaek, @lsmith77 --------------------------------------------------------------------------- by Seldaek at 2011/11/25 04:16:43 -0800 There are other meta-names available in the XmlEncoder, @-something for attributes, then there is something happening with a # but I'm not quite sure what. I'm just saying, maybe *item isn't the best name, if it introduces a third metacharacter. Apart from that I'm fine with it. --------------------------------------------------------------------------- by excelwebzone at 2011/11/25 08:45:31 -0800 Maybe we can rename it to `wildcard` instead --------------------------------------------------------------------------- by excelwebzone at 2011/11/25 15:12:09 -0800 Any chance we can push this throw? --------------------------------------------------------------------------- by lsmith77 at 2011/11/27 04:06:25 -0800 here is the old PR #2682 @Seldaek: i think your comment was made for an older version of the patch. overall I am fine with the change, the Serializer component takes a fairly simple approach. it is also not designed to really produce XML or JSON cleanly from the same data. it will really only be able to output a clean API for one or the other with the same data structure. --------------------------------------------------------------------------- by excelwebzone at 2011/12/01 06:25:24 -0800 @fabpot can we merge this change
This commit is contained in:
commit
d6f01df790
@ -162,6 +162,33 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
|||||||
* after login, the user is now redirected to `default_target_path` if `use_referer` is true and the referrer is the `login_path`.
|
* after login, the user is now redirected to `default_target_path` if `use_referer` is true and the referrer is the `login_path`.
|
||||||
* added a way to remove a token from a session
|
* added a way to remove a token from a session
|
||||||
|
|
||||||
|
### Serializer
|
||||||
|
|
||||||
|
* [BC BREAK] convert the `item` XML tag to an array
|
||||||
|
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<response>
|
||||||
|
<item><title><![CDATA[title1]]></title></item><item><title><![CDATA[title2]]></title></item>
|
||||||
|
</response>
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
Array()
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
Array(
|
||||||
|
[item] => Array(
|
||||||
|
[0] => Array(
|
||||||
|
[title] => title1
|
||||||
|
)
|
||||||
|
[1] => Array(
|
||||||
|
[title] => title2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Translation
|
### Translation
|
||||||
|
|
||||||
* added support for gettext
|
* added support for gettext
|
||||||
|
@ -191,11 +191,8 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
|||||||
if ($key === 'item') {
|
if ($key === 'item') {
|
||||||
if (isset($value['@key'])) {
|
if (isset($value['@key'])) {
|
||||||
$data[(string) $value['@key']] = $value['#'];
|
$data[(string) $value['@key']] = $value['#'];
|
||||||
} elseif (isset($data['item'])) {
|
} else {
|
||||||
$tmp = $data['item'];
|
$data['item'][] = $value;
|
||||||
unset($data['item']);
|
|
||||||
$data[] = $tmp;
|
|
||||||
$data[] = $value;
|
|
||||||
}
|
}
|
||||||
} elseif (array_key_exists($key, $data)) {
|
} elseif (array_key_exists($key, $data)) {
|
||||||
if ((false === is_array($data[$key])) || (false === isset($data[$key][0]))) {
|
if ((false === is_array($data[$key])) || (false === isset($data[$key][0]))) {
|
||||||
|
@ -239,6 +239,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
|||||||
'<foo><![CDATA[foo]]></foo>'.
|
'<foo><![CDATA[foo]]></foo>'.
|
||||||
'<bar><![CDATA[a]]></bar><bar><![CDATA[b]]></bar>'.
|
'<bar><![CDATA[a]]></bar><bar><![CDATA[b]]></bar>'.
|
||||||
'<baz><key><![CDATA[val]]></key><key2><![CDATA[val]]></key2><item key="A B"><![CDATA[bar]]></item>'.
|
'<baz><key><![CDATA[val]]></key><key2><![CDATA[val]]></key2><item key="A B"><![CDATA[bar]]></item>'.
|
||||||
|
'<item><title><![CDATA[title1]]></title></item><item><title><![CDATA[title2]]></title></item>'.
|
||||||
'<Barry><FooBar id="1"><Baz><![CDATA[Ed]]></Baz></FooBar></Barry></baz>'.
|
'<Barry><FooBar id="1"><Baz><![CDATA[Ed]]></Baz></FooBar></Barry></baz>'.
|
||||||
'<qux>1</qux>'.
|
'<qux>1</qux>'.
|
||||||
'</response>'."\n";
|
'</response>'."\n";
|
||||||
@ -249,7 +250,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$obj = new Dummy;
|
$obj = new Dummy;
|
||||||
$obj->foo = 'foo';
|
$obj->foo = 'foo';
|
||||||
$obj->bar = array('a', 'b');
|
$obj->bar = array('a', 'b');
|
||||||
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', "Barry" => array('FooBar' => array("Baz"=>"Ed", "@id"=>1)));
|
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1)));
|
||||||
$obj->qux = "1";
|
$obj->qux = "1";
|
||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
|
Reference in New Issue
Block a user