Added PHPWord_Exception and exception when could not copy the template
This commit is contained in:
parent
5d6bb15825
commit
1b849ec1bb
@ -30,3 +30,4 @@ Fixed in branch for release 0.7 :
|
|||||||
- General: (deds) - add indentation support to paragraphs
|
- General: (deds) - add indentation support to paragraphs
|
||||||
- General: (Progi1984) GH-27 - Support for Composer
|
- General: (Progi1984) GH-27 - Support for Composer
|
||||||
- General: (Progi1984) - Basic CI with Travis
|
- General: (Progi1984) - Basic CI with Travis
|
||||||
|
- General: (Progi1984) - Added PHPWord_Exception and exception when could not copy the template
|
||||||
52
src/PHPWord/Exception.php
Normal file
52
src/PHPWord/Exception.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009 - 2010 PHPWord
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPWord
|
||||||
|
* @package PHPWord
|
||||||
|
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHPWord_Exception
|
||||||
|
*
|
||||||
|
* @category PHPWord
|
||||||
|
* @package PHPWord
|
||||||
|
* @copyright Copyright (c) 2006 - 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
||||||
|
*/
|
||||||
|
class PHPWord_Exception extends Exception {
|
||||||
|
/**
|
||||||
|
* Error handler callback
|
||||||
|
*
|
||||||
|
* @param mixed $code
|
||||||
|
* @param mixed $string
|
||||||
|
* @param mixed $file
|
||||||
|
* @param mixed $line
|
||||||
|
* @param mixed $context
|
||||||
|
*/
|
||||||
|
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||||
|
$e = new self($string, $code);
|
||||||
|
$e->line = $line;
|
||||||
|
$e->file = $file;
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -66,7 +66,10 @@ class PHPWord_Template {
|
|||||||
$path = dirname($strFilename);
|
$path = dirname($strFilename);
|
||||||
$this->_tempFileName = $path.DIRECTORY_SEPARATOR.time().'.docx';
|
$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 = new ZipArchive();
|
||||||
$this->_objZip->open($this->_tempFileName);
|
$this->_objZip->open($this->_tempFileName);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user