Created
May 23, 2012 02:25
-
-
Save colindecarlo/2772887 to your computer and use it in GitHub Desktop.
persist method from the Persister abstract class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// interesting bits up here | |
public function persist() | |
{ | |
try { | |
// maybe do some preprocessing of the file | |
// make sure it's safe, etc | |
// call out to a protected method to actually store the file somewhere | |
$this->_persist(); | |
} catch (\Exception $e) { | |
// this exception will have some nitty gritty details useful for logging | |
$this->_logger->log( | |
'Unable to persist uploaded file: ' . $e->getMessage(), | |
Logger::LEVEL_OHNOES | |
); | |
// throw a new friendly exception | |
throw new \Exception( | |
'We were unable to store your file, maybe retry a little later?', | |
0, // we don't need no stinking error codes | |
$e | |
); | |
} | |
$this->_logger->log('Successfully stored uploaded file in: ' . $this->getLocation()); | |
return true; | |
} | |
// moar interesting bits down here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment