Hide backend controller behavior public methods from controller actions.
Fixes #3762, replaces #3764
This commit is contained in:
parent
9d28daa68a
commit
9fa7cbf70e
|
|
@ -79,6 +79,11 @@ class FormController extends ControllerBehavior
|
|||
*/
|
||||
protected $requiredConfig = ['modelClass', 'form'];
|
||||
|
||||
/**
|
||||
* @var array Visible actions in context of the controller
|
||||
*/
|
||||
protected $actions = ['create', 'update', 'preview'];
|
||||
|
||||
/**
|
||||
* @var string The context to pass to the form widget.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ class ImportExportController extends ControllerBehavior
|
|||
*/
|
||||
protected $requiredConfig = [];
|
||||
|
||||
/**
|
||||
* @var array Visible actions in context of the controller
|
||||
*/
|
||||
protected $actions = ['import', 'export', 'download'];
|
||||
|
||||
/**
|
||||
* @var Model Import model
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ class ListController extends ControllerBehavior
|
|||
*/
|
||||
protected $requiredConfig = ['modelClass', 'list'];
|
||||
|
||||
/**
|
||||
* @var array Visible actions in context of the controller
|
||||
*/
|
||||
protected $actions = ['index'];
|
||||
|
||||
/**
|
||||
* Behavior constructor
|
||||
* @param \Backend\Classes\Controller $controller
|
||||
|
|
|
|||
|
|
@ -85,6 +85,11 @@ class RelationController extends ControllerBehavior
|
|||
*/
|
||||
protected $requiredConfig = [];
|
||||
|
||||
/**
|
||||
* @var array Visible actions in context of the controller
|
||||
*/
|
||||
protected $actions = [];
|
||||
|
||||
/**
|
||||
* @var array Original configuration values
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ class ReorderController extends ControllerBehavior
|
|||
*/
|
||||
protected $requiredConfig = ['modelClass'];
|
||||
|
||||
/**
|
||||
* @var array Visible actions in context of the controller
|
||||
*/
|
||||
protected $actions = ['reorder'];
|
||||
|
||||
/**
|
||||
* @var Model Import model
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ class ControllerBehavior extends ExtensionBase
|
|||
*/
|
||||
protected $requiredProperties = [];
|
||||
|
||||
/**
|
||||
* @var array Visible actions in context of the controller. Only takes effect if it is an array
|
||||
*/
|
||||
protected $actions;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
|
@ -58,6 +63,11 @@ class ControllerBehavior extends ExtensionBase
|
|||
]));
|
||||
}
|
||||
}
|
||||
|
||||
// Hide all methods that aren't explicitly listed as actions
|
||||
if (is_array($this->actions)) {
|
||||
$this->hideAction(array_diff(get_class_methods(get_class($this)), $this->actions));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue