BUGFIX: catch any errors thrown by incorrect paths nicer

This commit is contained in:
Will Rossiter 2010-10-22 01:08:44 +00:00
parent 354aa95e2b
commit 0be89228e7

View File

@ -58,7 +58,7 @@ class DocumentationPage extends ViewableData {
* @return String
*/
function getPath() {
$path = realpath(rtrim($this->entity->getPath($this->version, $this->lang), '/') . '/' . $this->getRelativePath());
$path = realpath(rtrim($this->entity->getPath($this->version, $this->lang), '/') . '/' . trim($this->getRelativePath(), '/'));
if(!file_exists($path)) {
throw new InvalidArgumentException(sprintf(
@ -91,7 +91,14 @@ class DocumentationPage extends ViewableData {
* @return String
*/
function getMarkdown() {
return file_get_contents($this->getPath());
try {
$path = $this->getPath();
return file_get_contents($path);
}
catch(InvalidArgumentException $e) {}
return null;
}
/**