mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 12:05:56 +00:00
APICHANGE: add one more handy interface method addPages($pageIDs).
MINOR: correct inline document to reflect the evolved data model.
This commit is contained in:
parent
de93686a68
commit
399754c551
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
class DMSDocument extends DataObject implements DMSDocumentInterface {
|
||||
|
||||
static $db = array(
|
||||
"Filename" => "Varchar(255)", // eg. 3469~2011-energysaving-report.pdf
|
||||
"Folder" => "Varchar(255)", // eg. 0
|
||||
@ -15,13 +14,29 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
||||
|
||||
/**
|
||||
* Associates this document with a Page. This method does nothing if the association already exists.
|
||||
* This could be a simple wrapper around $myDoc->Pages()->add($myPage) to add a has_many relation
|
||||
* This could be a simple wrapper around $myDoc->Pages()->add($myPage) to add a many_many relation
|
||||
* @param $pageObject Page object to associate this Document with
|
||||
* @return null
|
||||
*/
|
||||
function addPage($pageObject) {
|
||||
$this->Pages()->add($pageObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates this DMSDocument with a set of Pages. This method loops through a set of page ids, and then associates this
|
||||
* DMSDocument with the individual Page with the each page id in the set
|
||||
* @abstract
|
||||
* @param $pageIDs array of page ids used for the page objects associate this DMSDocument with
|
||||
* @return null
|
||||
*/
|
||||
function addPages($pageIDs){
|
||||
foreach($pageIDs as $id){
|
||||
$pageObject = DataObject::get_by_id("SiteTree", $id);
|
||||
if($pageObject && $pageObject->exists()) {
|
||||
$this->addPage($pageObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the association between this Document and a Page. This method does nothing if the association does not exist.
|
||||
|
@ -18,12 +18,21 @@ interface DMSDocumentInterface {
|
||||
|
||||
/**
|
||||
* Associates this DMSDocument with a Page. This method does nothing if the association already exists.
|
||||
* This could be a simple wrapper around $myDoc->Pages()->add($myPage) to add a has_many relation
|
||||
* This could be a simple wrapper around $myDoc->Pages()->add($myPage) to add a many_many relation
|
||||
* @abstract
|
||||
* @param $pageObject Page object to associate this DMSDocument with
|
||||
* @return null
|
||||
*/
|
||||
function addPage($pageObject);
|
||||
|
||||
/**
|
||||
* Associates this DMSDocument with a set of Pages. This method loops through a set of page ids, and then associates this
|
||||
* DMSDocument with the individual Page with the each page id in the set
|
||||
* @abstract
|
||||
* @param $pageIDs array of page ids used for the page objects associate this DMSDocument with
|
||||
* @return null
|
||||
*/
|
||||
function addPages($pageIDs);
|
||||
|
||||
/**
|
||||
* Removes the association between this DMSDocument and a Page. This method does nothing if the association does not exist.
|
||||
|
Loading…
x
Reference in New Issue
Block a user