private function processSpineElement(SimpleXMLElement $xml, Spine $spine, Manifest $manifest, Navigation $navigation) { $position = 1; foreach ($xml->itemref as $child) { $id = (string) $child['idref']; $manifestItem = $manifest->get($id); if (!($linear = $child['linear'])) { $linear = 'yes'; } $item = new SpineItem(); $item->id = $id; $item->type = $manifestItem->type; $item->href = $manifestItem->href; $item->order = $position; $item->linear = $linear; $this->addContentGetter($item); $spine->add($item); $position++; } $ncxId = $xml['toc'] ? (string) $xml['toc'] : 'ncx'; if ($manifest->has($ncxId)) { $navigation->src = $manifest->get($ncxId); } }
private function appendSpineElement(\DOMDocument $document, Spine $spine) { $node = $document->createElement('spine'); $node->setAttribute('toc', 'ncx'); foreach ($spine->all() as $item) { // $child = $document->createElementNS(NamespaceRegistry::NAMESPACE_DC, $item->name, $item->value); $child = $document->createElement('itemref'); $child->setAttribute('idref', $item->id); $node->appendChild($child); } return $node; }