BUGFIX: renaming method to prevent conflicts

This commit is contained in:
Julian Seidenberg 2012-07-30 12:33:01 +12:00
parent 17ea520f98
commit e0c028f87f
4 changed files with 18 additions and 14 deletions

View File

@ -142,7 +142,7 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
* @param null $value String of the value of the tag to get * @param null $value String of the value of the tag to get
* @return array of Strings of all the tags or null if there is no match found * @return array of Strings of all the tags or null if there is no match found
*/ */
function getTags($category, $value = null) { function getTagsList($category, $value = null) {
$tags = $this->getTagsObjects($category, $value); $tags = $this->getTagsObjects($category, $value);
//convert DataList into array of Values //convert DataList into array of Values
@ -458,5 +458,9 @@ class DMSDocument_Controller extends Controller {
$this->httpError(404, 'This asset does not exist.'); $this->httpError(404, 'This asset does not exist.');
} }
function getCMSFields() {
return parent::getCMSFields();
}
} }

View File

@ -5,7 +5,7 @@ class DMSSiteTreeExtension extends DataExtension {
'Documents' => 'DMSDocument' 'Documents' => 'DMSDocument'
); );
function updateCMSFields(&$fields){ function updateCMSFields(FieldList $fields){
$documentsListConfig = GridFieldConfig_RecordEditor::create(); $documentsListConfig = GridFieldConfig_RecordEditor::create();
$modelClass = DMS::$modelClass; $modelClass = DMS::$modelClass;
$documentsListConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields($modelClass::$display_fields); $documentsListConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields($modelClass::$display_fields);
@ -13,7 +13,7 @@ class DMSSiteTreeExtension extends DataExtension {
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Documents', 'Root.Documents',
GridField::create( GridField::create(
'Documents', 'Documents',
false, false,
$this->owner->Documents(), $this->owner->Documents(),
$documentsListConfig $documentsListConfig

View File

@ -79,7 +79,7 @@ interface DMSDocumentInterface {
* @param null $value String of the value of the tag to get * @param null $value String of the value of the tag to get
* @return array of Strings of all the tags or null if there is no match found * @return array of Strings of all the tags or null if there is no match found
*/ */
function getTags($category, $value = null); function getTagsList($category, $value = null);
/** /**
* Quick way to add multiple tags to a DMSDocument. This takes a multidimensional array of category/value pairs. * Quick way to add multiple tags to a DMSDocument. This takes a multidimensional array of category/value pairs.

View File

@ -26,7 +26,7 @@ class DMSTagTest extends SapphireTest {
$doc->addTag("company","apple"); $doc->addTag("company","apple");
$doc->addTag("company","SilverStripe"); $doc->addTag("company","SilverStripe");
$fruits = $doc->getTags("fruit"); $fruits = $doc->getTagsList("fruit");
$this->assertNotNull($fruits,"Something returned for fruit tags"); $this->assertNotNull($fruits,"Something returned for fruit tags");
$this->assertEquals(count($fruits),3,"3 fruit tags returned"); $this->assertEquals(count($fruits),3,"3 fruit tags returned");
$this->assertTrue(in_array("banana",$fruits),"correct fruit tags returned"); $this->assertTrue(in_array("banana",$fruits),"correct fruit tags returned");
@ -38,7 +38,7 @@ class DMSTagTest extends SapphireTest {
$doc2->write(); $doc2->write();
$doc2->addTag("fruit","banana"); $doc2->addTag("fruit","banana");
$fruits = $doc2->getTags("fruit"); $fruits = $doc2->getTagsList("fruit");
$this->assertNotNull($fruits,"Something returned for fruit tags"); $this->assertNotNull($fruits,"Something returned for fruit tags");
$this->assertEquals(count($fruits),1,"Only 1 fruit tags returned"); $this->assertEquals(count($fruits),1,"Only 1 fruit tags returned");
@ -46,7 +46,7 @@ class DMSTagTest extends SapphireTest {
$doc->removeAllTags(); $doc->removeAllTags();
//banana fruit remains //banana fruit remains
$fruits = $doc2->getTags("fruit"); $fruits = $doc2->getTagsList("fruit");
$this->assertNotNull($fruits,"Something returned for fruit tags"); $this->assertNotNull($fruits,"Something returned for fruit tags");
$this->assertEquals(count($fruits),1,"Only 1 fruit tags returned"); $this->assertEquals(count($fruits),1,"Only 1 fruit tags returned");
@ -72,41 +72,41 @@ class DMSTagTest extends SapphireTest {
$doc->addTag("company","apple"); $doc->addTag("company","apple");
$doc->addTag("company","SilverStripe"); $doc->addTag("company","SilverStripe");
$companies = $doc->getTags("company"); $companies = $doc->getTagsList("company");
$this->assertNotNull($companies,"Companies returned before deletion"); $this->assertNotNull($companies,"Companies returned before deletion");
$this->assertEquals(count($companies),2,"Two companies returned before deletion"); $this->assertEquals(count($companies),2,"Two companies returned before deletion");
//delete an entire category //delete an entire category
$doc->removeTag("company"); $doc->removeTag("company");
$companies = $doc->getTags("company"); $companies = $doc->getTagsList("company");
$this->assertNull($companies,"All companies deleted"); $this->assertNull($companies,"All companies deleted");
$fruit = $doc->getTags("fruit"); $fruit = $doc->getTagsList("fruit");
$this->assertEquals(count($fruit),3,"Three fruits returned before deletion"); $this->assertEquals(count($fruit),3,"Three fruits returned before deletion");
//delete a single tag //delete a single tag
$doc->removeTag("fruit","apple"); $doc->removeTag("fruit","apple");
$fruit = $doc->getTags("fruit"); $fruit = $doc->getTagsList("fruit");
$this->assertEquals(count($fruit),2,"Two fruits returned after deleting one"); $this->assertEquals(count($fruit),2,"Two fruits returned after deleting one");
//delete a single tag //delete a single tag
$doc->removeTag("fruit","orange"); $doc->removeTag("fruit","orange");
$fruit = $doc->getTags("fruit"); $fruit = $doc->getTagsList("fruit");
$this->assertEquals(count($fruit),1,"One fruits returned after deleting two"); $this->assertEquals(count($fruit),1,"One fruits returned after deleting two");
//nothing happens when deleting tag that doesn't exist //nothing happens when deleting tag that doesn't exist
$doc->removeTag("fruit","jellybean"); $doc->removeTag("fruit","jellybean");
$fruit = $doc->getTags("fruit"); $fruit = $doc->getTagsList("fruit");
$this->assertEquals(count($fruit),1,"One fruits returned after attempting to delete non-existent fruit"); $this->assertEquals(count($fruit),1,"One fruits returned after attempting to delete non-existent fruit");
//delete the last fruit //delete the last fruit
$doc->removeTag("fruit","banana"); $doc->removeTag("fruit","banana");
$fruit = $doc->getTags("fruit"); $fruit = $doc->getTagsList("fruit");
$this->assertNull($fruit,"All fruits deleted"); $this->assertNull($fruit,"All fruits deleted");
$tags = DataObject::get("DMSTag"); $tags = DataObject::get("DMSTag");