From 6577324a9c736fd9cdbccb8a70bc23ca5cf3c4c7 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Wed, 20 Aug 2014 11:14:46 +0100 Subject: [PATCH] Removing duplicate code and keeping File API consistent --- filesystem/File.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/filesystem/File.php b/filesystem/File.php index 8682146eb..6a9668e7d 100644 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -248,12 +248,31 @@ class File extends DataObject { return $item; } + /** + * Just an alias function to keep a consistent API with SiteTree + * + * @return string The link to the file + */ public function Link() { - return Director::baseURL() . $this->RelativeLink(); + return $this->getURL(); } + /** + * Just an alias function to keep a consistent API with SiteTree + * + * @return string The relative link to the file + */ public function RelativeLink() { - return $this->Filename; + return $this->getFilename(); + } + + /** + * Just an alias function to keep a consistent API with SiteTree + * + * @return string The absolute link to the file + */ + public function AbsoluteLink() { + return $this->getAbsoluteURL(); } /** @@ -671,7 +690,7 @@ class File extends DataObject { * @return string */ public function getAbsoluteURL() { - return Director::absoluteBaseURL() . $this->getFilename(); + return Director::absoluteURL($this->getURL()); } /** @@ -681,7 +700,7 @@ class File extends DataObject { * @return string */ public function getURL() { - return Director::baseURL() . $this->getFilename(); + return Controller::join_links(Director::baseURL(), $this->getFilename()); } /**