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
|
<?php
|
||||||
class DMSDocument extends DataObject implements DMSDocumentInterface {
|
class DMSDocument extends DataObject implements DMSDocumentInterface {
|
||||||
|
|
||||||
static $db = array(
|
static $db = array(
|
||||||
"Filename" => "Varchar(255)", // eg. 3469~2011-energysaving-report.pdf
|
"Filename" => "Varchar(255)", // eg. 3469~2011-energysaving-report.pdf
|
||||||
"Folder" => "Varchar(255)", // eg. 0
|
"Folder" => "Varchar(255)", // eg. 0
|
||||||
@ -15,7 +14,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates this document with a Page. This method does nothing if the association already exists.
|
* 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
|
* @param $pageObject Page object to associate this Document with
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
@ -23,6 +22,22 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
$this->Pages()->add($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.
|
* Removes the association between this Document and a Page. This method does nothing if the association does not exist.
|
||||||
* @param $pageObject Page object to remove the association to
|
* @param $pageObject Page object to remove the association to
|
||||||
|
@ -18,13 +18,22 @@ interface DMSDocumentInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates this DMSDocument with a Page. This method does nothing if the association already exists.
|
* 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
|
* @abstract
|
||||||
* @param $pageObject Page object to associate this DMSDocument with
|
* @param $pageObject Page object to associate this DMSDocument with
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
function addPage($pageObject);
|
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.
|
* Removes the association between this DMSDocument and a Page. This method does nothing if the association does not exist.
|
||||||
* @abstract
|
* @abstract
|
||||||
|
Loading…
x
Reference in New Issue
Block a user