We could serialize to PGNXML and PGN text by leveraging Symfony XmlEncoder and a custom PgnEncoder.

Pseudocode attached.

CommentFileSizeAuthor
#26 pgn-encoder-1959028-26.patch281.14 KBeric_a
#23 interdiff.txt790 byteseric_a
#23 pgn-encoder-1959028-23.patch279.77 KBeric_a
#22 interdiff.txt580 byteseric_a
#22 pgn-encoder-1959028-22.patch279.78 KBeric_a
#19 interdiff.txt681 byteseric_a
#19 pgn-encoder-1959028-19.patch279.75 KBeric_a
#18 interdiff.txt1.01 KBeric_a
#18 pgn-encoder-test-1959028-18.patch277.37 KBeric_a
#18 pgn-encoder-1959028-18.patch279.69 KBeric_a
#17 interdiff.txt701 byteseric_a
#17 pgn-encoder-test-1959028-17.patch277.4 KBeric_a
#17 pgn-encoder-1959028-17.patch279.68 KBeric_a
#15 interdiff.txt639 byteseric_a
#15 pgn-encoder-test-1959028-15.patch277.33 KBeric_a
#15 pgn-encoder-1959028-15.patch279.62 KBeric_a
#13 interdiff.txt612 byteseric_a
#13 pgn-encoder-test-1959028-13.patch277.34 KBeric_a
#13 pgn-encoder-1959028-13.patch279.62 KBeric_a
#12 interdiff.txt439 byteseric_a
#12 pgn-encoder-test-1959028-12.patch277.17 KBeric_a
#12 pgn-encoder-1959028-12.patch279.45 KBeric_a
#11 pgn-encoder-test-1959028-11.patch277.11 KBeric_a
#11 pgn-encoder-1959028-11.patch279.4 KBeric_a
#10 interdiff.txt665 byteseric_a
#10 pgn-encoder-test-1959028-10.patch278.1 KBeric_a
#10 pgn-encoder-1959028-10.patch280.38 KBeric_a
#8 interdiff.txt997 byteseric_a
#8 pgn-encoder-test-1959028-8.patch278.1 KBeric_a
#8 pgn-encoder-1959028-8.patch280.38 KBeric_a
#1 pgn-encoder-test-1959028-1.patch277.83 KBeric_a
#1 pgn-encoder-1959028-1.patch280.11 KBeric_a
#5 interdiff.txt900 byteseric_a
#5 pgn-encoder-test-1959028-5.patch278.02 KBeric_a
#5 pgn-encoder-1959028-5.patch280.3 KBeric_a
#3 interdiff.txt472 byteseric_a
#3 pgn-encoder-test-1959028-3.patch277.86 KBeric_a
#3 pgn-encoder-1959028-3.patch280.14 KBeric_a
pgn-encoder.patch1.94 KBeric_a

Comments

eric_a’s picture

StatusFileSize
new280.11 KB
new277.83 KB

This is the PGNXML encoder.

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-1.patch, failed testing.

eric_a’s picture

Status: Needs work » Needs review
StatusFileSize
new280.14 KB
new277.86 KB
new472 bytes

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-3.patch, failed testing.

eric_a’s picture

Status: Needs work » Needs review
StatusFileSize
new280.3 KB
new278.02 KB
new900 bytes

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-5.patch, failed testing.

eric_a’s picture

Status: Needs work » Needs review
+    $this->pgnxml = strtr($this->pgnxml, array("\n" => ''));

That was a truly terrible try... and of course it did not work.

eric_a’s picture

StatusFileSize
new280.38 KB
new278.1 KB
new997 bytes

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-8.patch, failed testing.

eric_a’s picture

Status: Needs work » Needs review
StatusFileSize
new280.38 KB
new278.1 KB
new665 bytes
eric_a’s picture

StatusFileSize
new279.4 KB
new277.11 KB

White space fixes...

eric_a’s picture

StatusFileSize
new279.45 KB
new277.17 KB
new439 bytes

Added XML namespace to root element.

eric_a’s picture

StatusFileSize
new279.62 KB
new277.34 KB
new612 bytes

Test decoding.

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-13.patch, failed testing.

eric_a’s picture

Status: Needs work » Needs review
StatusFileSize
new279.62 KB
new277.33 KB
new639 bytes

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-15.patch, failed testing.

eric_a’s picture

Status: Needs work » Needs review
StatusFileSize
new279.68 KB
new277.4 KB
new701 bytes
eric_a’s picture

StatusFileSize
new279.69 KB
new277.37 KB
new1.01 KB

Apparently the Symfony XmlEncoder does not handle the namespace. Let's just do that ourselves.

eric_a’s picture

StatusFileSize
new279.75 KB
new681 bytes

Introduced injection of the Symfony Encoder. (We'll do some mocking in a separate D8-only issue.)
No changes to the test.

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-19.patch, failed testing.

eric_a’s picture

Status: Needs work » Needs review

#19: pgn-encoder-1959028-19.patch queued for re-testing.

eric_a’s picture

StatusFileSize
new279.78 KB
new580 bytes
eric_a’s picture

StatusFileSize
new279.77 KB
new790 bytes
eric_a’s picture

Title: Add PGN serializing » Add a PGNXML encoder
eric_a’s picture

Status: Needs review » Patch (to be ported)
Issue tags: +Needs backport to D7

Pushed to 8.x-1.x. Moving to 7.x-1.x.

eric_a’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new281.14 KB

#1970094: Convert XmlEncoderUnitTest to a UnitTestBase has landed, so now we have a type of test that has an equivalent in Drupal 7.

Status: Needs review » Needs work

The last submitted patch, pgn-encoder-1959028-26.patch, failed testing.

eric_a’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review
eric_a’s picture

#26: pgn-encoder-1959028-26.patch queued for re-testing.

eric_a’s picture

Status: Needs review » Fixed

Pushed #26 to 7.x-1.x.

Automatically closed -- issue fixed for 2 weeks with no activity.