mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
BUGFIX: catch any errors thrown by incorrect paths nicer
This commit is contained in:
parent
354aa95e2b
commit
0be89228e7
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user