API Changed DMSDocument getters to be closer to existing File API

Reduces friction when migration from File records (which will be fairly common)
This commit is contained in:
Ingo Schommer 2012-08-22 23:20:48 +02:00
parent 2038fb9829
commit 234ccb3b1c
2 changed files with 21 additions and 7 deletions

View File

@ -236,7 +236,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
* Returns a link to download this document from the DMS store * Returns a link to download this document from the DMS store
* @return String * @return String
*/ */
function getDownloadLink() { function getLink() {
return Controller::join_links(Director::baseURL(),'dmsdocument/'.$this->ID); return Controller::join_links(Director::baseURL(),'dmsdocument/'.$this->ID);
} }
@ -624,14 +624,19 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
/** /**
* Return the extension of the file associated with the document * Return the extension of the file associated with the document
*/ */
function getFileExt() { function getExtension() {
return strtolower(pathinfo($this->Filename, PATHINFO_EXTENSION)); return strtolower(pathinfo($this->Filename, PATHINFO_EXTENSION));
} }
function getSize() {
$size = $this->getAbsoluteSize();
return ($size) ? File::format_size($size) : false;
}
/** /**
* Return the size of the file associated with the document * Return the size of the file associated with the document
*/ */
function getFileSize() { function getAbsoluteSize() {
return filesize($this->getFullPath()); return filesize($this->getFullPath());
} }

View File

@ -130,17 +130,26 @@ interface DMSDocumentInterface {
* @abstract * @abstract
* @return String * @return String
*/ */
function getDownloadLink(); function getLink();
/** /**
* Return the extension of the file associated with the document * Return the extension of the file associated with the document
*/ */
function getFileExt(); function getExtension();
/** /**
* Return the size of the file associated with the document * Returns the size of the file type in an appropriate format.
*
* @return string
*/ */
function getFileSize(); function getSize();
/**
* Return the size of the file associated with the document, in bytes.
*
* @return int
*/
function getAbsoluteSize();
/** /**