Hide backend controller behavior public methods from controller actions.

Fixes #3762, replaces #3764
This commit is contained in:
Luke Towers 2019-04-19 14:01:01 -06:00
parent 9d28daa68a
commit 9fa7cbf70e
6 changed files with 35 additions and 0 deletions

View File

@ -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.
*/

View File

@ -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
*/

View File

@ -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

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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));
}
}
/**