Skip to content

Commit e9cd17d

Browse files
Add destructor wich will try to clean up temp file of the template
processor
1 parent aca1078 commit e9cd17d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/PhpWord/TemplateProcessor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ public function __construct($documentTemplate)
132132
$this->tempDocumentContentTypes = $this->zipClass->getFromName($this->getDocumentContentTypesName());
133133
}
134134

135+
public function __destruct()
136+
{
137+
// if the temp file still exists, remove it when running destruct
138+
if ($this->tempDocumentFilename && file_exists($this->tempDocumentFilename) && is_writable($this->tempDocumentFilename)) {
139+
@unlink($this->tempDocumentFilename);
140+
}
141+
}
142+
135143
/**
136144
* Expose zip class
137145
*

0 commit comments

Comments
 (0)