Skip to content

Commit

Permalink
Merge pull request #57 from RomanSyroeshko/PHPWord#56
Browse files Browse the repository at this point in the history
Postprocessing of documents returned by Template class before moving to final destination
  • Loading branch information
Progi1984 committed Mar 3, 2014
2 parents 1567756 + 3cd60f7 commit cc61801
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Classes/PHPWord/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,31 @@ public function getVariables()
/**
* Save Template
*
* @param string $strFilename
* @return string
*/
public function save($strFilename)
{
if (file_exists($strFilename)) {
unlink($strFilename);
}

public function save() {
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);

// Close zip file
if ($this->_objZip->close() === false) {
throw new Exception('Could not close zip file.');
}

rename($this->_tempFileName, $strFilename);
return $this->_tempFileName;
}

/**
* Save Template As...
*
* @param string $strFilename
*/
public function saveAs($strFilename) {
$tempFilename = $this->save();

if (file_exists($strFilename)) {
unlink($strFilename);
}

rename($tempFilename, $strFilename);
}
}
}

0 comments on commit cc61801

Please sign in to comment.