Skip to content

Commit cc61801

Browse files
committed
Merge pull request #57 from RomanSyroeshko/PHPWord#56
Postprocessing of documents returned by Template class before moving to final destination
2 parents 1567756 + 3cd60f7 commit cc61801

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

Classes/PHPWord/Template.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,31 @@ public function getVariables()
117117
/**
118118
* Save Template
119119
*
120-
* @param string $strFilename
120+
* @return string
121121
*/
122-
public function save($strFilename)
123-
{
124-
if (file_exists($strFilename)) {
125-
unlink($strFilename);
126-
}
127-
122+
public function save() {
128123
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
129124

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

135-
rename($this->_tempFileName, $strFilename);
130+
return $this->_tempFileName;
131+
}
132+
133+
/**
134+
* Save Template As...
135+
*
136+
* @param string $strFilename
137+
*/
138+
public function saveAs($strFilename) {
139+
$tempFilename = $this->save();
140+
141+
if (file_exists($strFilename)) {
142+
unlink($strFilename);
143+
}
144+
145+
rename($tempFilename, $strFilename);
136146
}
137-
}
147+
}

0 commit comments

Comments
 (0)