ENHANCEMENT Allowing strings instead of arrays in ModelAdmin::$managed_models to make it less error-prone for beginners

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@65463 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-11-09 14:34:05 +00:00
parent 6db9650b32
commit 231e3f0003

View File

@ -34,7 +34,7 @@ abstract class ModelAdmin extends LeftAndMain {
/**
* List of all managed {@link DataObject}s in this interface.
*
* @var array
* @var array|string
*/
protected static $managed_models = null;
@ -195,6 +195,7 @@ abstract class ModelAdmin extends LeftAndMain {
*/
protected function getManagedModels() {
$models = $this->stat('managed_models');
if(is_string($models)) $models = array($models);
if(!count($models)) user_error('ModelAdmin::getManagedModels():
You need to specify at least one DataObject subclass in protected static $managed_models.
Make sure the visibility of your property is set to "protected"',