getDomFromZip($this->docFile, $this->xmlFile); $docSettings = $phpWord->getSettings(); $nodes = $xmlReader->getElements('*'); if ($nodes->length > 0) { foreach ($nodes as $node) { $name = str_replace('w:', '', $node->nodeName); $value = $xmlReader->getAttribute('w:val', $node); $method = 'set' . $name; if (in_array($name, $this::$booleanProperties)) { if ($value == 'false') { $docSettings->$method(false); } else { $docSettings->$method(true); } } else if (method_exists($this, $method)) { $this->$method($xmlReader, $phpWord, $node); } else if (method_exists($this, $method)) { $docSettings->$method($value); } } } } /** * Sets the document protection * * @param XMLReader $xmlReader * @param PhpWord $phpWord * @param \DOMNode $node */ protected function setDocumentProtection(XMLReader $xmlReader, PhpWord $phpWord, \DOMNode $node) { $documentProtection = $phpWord->getSettings()->getDocumentProtection(); $edit = $xmlReader->getAttribute('w:edit', $node); $documentProtection->setEditing($edit); } }