BUGFIX: Allow disabling of updateCMSFields() on SiteTree so subclasses that want decorators to have access to

their added fields can call it themselves. 


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2@64634 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2008-10-22 03:38:10 +00:00 committed by Sam Minnee
parent a7bc06c656
commit 4c73c41ca9

View File

@ -184,7 +184,11 @@ class SiteTree extends DataObject {
* @var string
*/
public static $breadcrumbs_delimiter = " » ";
/**
* This controls whether of not extendCMSFields() is called by getCMSFields.
*/
private static $runCMSFieldsExtensions = true;
/**
* Get the URL for this page.
@ -1115,8 +1119,10 @@ class SiteTree extends DataObject {
$tabReports->setTitle(_t('SiteTree.TABREPORTS', "Reports"));
$tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
$tabBacklinks->setTitle(_t('SiteTree.TABBACKLINKS', "BackLinks"));
$this->extend('updateCMSFields', $fields);
if(self::$runCMSFieldsExtensions) {
$this->extend('updateCMSFields', $fields);
}
return $fields;
}
@ -1426,6 +1432,24 @@ class SiteTree extends DataObject {
return $classes;
}
/**
* Stops extendCMSFields() being called on getCMSFields().
* This is useful when you need access to fields added by subclasses
* of SiteTree in a decorator. Call before calling parent::getCMSFields(),
* and reenable afterwards.
*/
public static function disableCMSFieldsExtensions() {
self::$runCMSFieldsExtensions = false;
}
/**
* Reenables extendCMSFields() being called on getCMSFields() after
* it has been disabled by disableCMSFieldsExtensions().
*/
public static function enableCMSFieldsExtensions() {
self::$runCMSFieldsExtensions = true;
}
}
?>