1<?php 2 3namespace FINDOLOGIC\Export\XML; 4 5use FINDOLOGIC\Export\Exporter; 6 7class XMLExporter extends Exporter 8{ 9 /** 10 * @inheritdoc 11 */ 12 public function serializeItems($items, $start, $count, $total) 13 { 14 $page = new Page($start, $count, $total); 15 $page->setAllItems($items); 16 $xmlDocument = $page->getXml(); 17 18 return $xmlDocument->saveXML(); 19 } 20 21 /** 22 * @inheritdoc 23 */ 24 public function serializeItemsToFile($targetDirectory, $items, $start, $count, $total) 25 { 26 $xmlString = $this->serializeItems($items, $start, $count, $total); 27 $targetPath = sprintf('%s/findologic_%d_%d.xml', $targetDirectory, $start, $count); 28 29 file_put_contents($targetPath, $xmlString); 30 31 return $targetPath; 32 } 33 34 /** 35 * @inheritdoc 36 */ 37 public function createItem($id) 38 { 39 return new XMLItem($id); 40 } 41} 42