From 1b849ec1bb7d01ef1f1babc27fa380fa1b8fc637 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 15 Dec 2013 13:18:07 +0100 Subject: [PATCH] Added PHPWord_Exception and exception when could not copy the template --- changelog.txt | 3 ++- src/PHPWord/Exception.php | 52 +++++++++++++++++++++++++++++++++++++++ src/PHPWord/Template.php | 7 ++++-- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/PHPWord/Exception.php diff --git a/changelog.txt b/changelog.txt index 7ce6daa9..72b9644c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -29,4 +29,5 @@ Fixed in branch for release 0.7 : - General: (MarkBaker) - Add superscript/subscript styling in Excel2007 Writer - General: (deds) - add indentation support to paragraphs - General: (Progi1984) GH-27 - Support for Composer -- General: (Progi1984) - Basic CI with Travis \ No newline at end of file +- General: (Progi1984) - Basic CI with Travis +- General: (Progi1984) - Added PHPWord_Exception and exception when could not copy the template \ No newline at end of file diff --git a/src/PHPWord/Exception.php b/src/PHPWord/Exception.php new file mode 100644 index 00000000..1cf4f050 --- /dev/null +++ b/src/PHPWord/Exception.php @@ -0,0 +1,52 @@ +line = $line; + $e->file = $file; + throw $e; + } +} \ No newline at end of file diff --git a/src/PHPWord/Template.php b/src/PHPWord/Template.php index 72004253..bbc3197f 100644 --- a/src/PHPWord/Template.php +++ b/src/PHPWord/Template.php @@ -65,8 +65,11 @@ class PHPWord_Template { public function __construct($strFilename) { $path = dirname($strFilename); $this->_tempFileName = $path.DIRECTORY_SEPARATOR.time().'.docx'; - - copy($strFilename, $this->_tempFileName); // Copy the source File to the temp File + + // Copy the source File to the temp File + if(!copy($strFilename, $this->_tempFileName)){ + throw new PHPWord_Exception('Could not copy the template from '.$strFilename.' to '.$this->_tempFileName.'.'); + } $this->_objZip = new ZipArchive(); $this->_objZip->open($this->_tempFileName);