mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX: removing hardcoded reference to ModelAdmin_RecordController, also added getters for model controllers. (from r97231)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102714 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
abe2496b20
commit
52d067ead4
@ -166,6 +166,43 @@ abstract class ModelAdmin extends LeftAndMain {
|
||||
static function get_page_length(){
|
||||
return self::$page_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class name of the collection controller
|
||||
*
|
||||
* @param string $model model name to get the controller for
|
||||
* @return string the collection controller class
|
||||
*/
|
||||
function getCollectionControllerClass($model) {
|
||||
$models = $this->getManagedModels();
|
||||
|
||||
if(isset($models[$model]['collection_controller'])) {
|
||||
$class = $models[$model]['collection_controller'];
|
||||
} else {
|
||||
$class = $this->stat('collection_controller_class');
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class name of the record controller
|
||||
*
|
||||
* @param string $model model name to get the controller for
|
||||
* @return string the record controller class
|
||||
*/
|
||||
function getRecordControllerClass($model) {
|
||||
$models = $this->getManagedModels();
|
||||
|
||||
if(isset($models[$model]['record_controller'])) {
|
||||
$class = $models[$model]['record_controller'];
|
||||
} else {
|
||||
$class = $this->stat('record_controller_class');
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mappings for generic form constructors to automatically delegate to a scaffolded form object.
|
||||
*/
|
||||
@ -182,14 +219,7 @@ abstract class ModelAdmin extends LeftAndMain {
|
||||
* Base scaffolding method for returning a generic model instance.
|
||||
*/
|
||||
public function bindModelController($model, $request = null) {
|
||||
$models = $this->getManagedModels();
|
||||
|
||||
if(isset($models[$model]['collection_controller'])) {
|
||||
$class = $models[$model]['collection_controller'];
|
||||
} else {
|
||||
$class = $this->stat('collection_controller_class');
|
||||
}
|
||||
|
||||
$class = $this->getCollectionControllerClass($model);
|
||||
return new $class($this, $model);
|
||||
}
|
||||
|
||||
@ -335,15 +365,7 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
* @return RecordController
|
||||
*/
|
||||
public function handleID($request) {
|
||||
$models = $this->parentController->getManagedModels();
|
||||
$model = $this->getModelClass();
|
||||
|
||||
if(isset($models[$model]['record_controller'])) {
|
||||
$class = $models[$model]['record_controller'];
|
||||
} else {
|
||||
$class = $this->parentController->stat('record_controller_class');
|
||||
}
|
||||
|
||||
$class = $this->parentController->getRecordControllerClass($this->getModelClass());
|
||||
return new $class($this, $request);
|
||||
}
|
||||
|
||||
@ -814,7 +836,8 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
$model->write();
|
||||
|
||||
if(Director::is_ajax()) {
|
||||
$recordController = new ModelAdmin_RecordController($this, $request, $model->ID);
|
||||
$class = $this->parentController->getRecordControllerClass($this->getModelClass());
|
||||
$recordController = new $class($this, $request, $model->ID);
|
||||
return new SS_HTTPResponse(
|
||||
$recordController->EditForm()->formHtmlContent(),
|
||||
200,
|
||||
|
Loading…
Reference in New Issue
Block a user