Skip to content

Commit

Permalink
Merge pull request #306 from FriendsOfCake/disabled-actions
Browse files Browse the repository at this point in the history
Auto blacklist disabled actions.
  • Loading branch information
ADmad committed Dec 19, 2022
2 parents c9c21a4 + c9a2d46 commit 0e993e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Listener/Traits/FormTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ protected function _getDefaultExtraLeftButtons(): array
$action = $this->_action();
if ($action instanceof EditAction) {
$blacklist = $action->getConfig('scaffold.actions_blacklist', []);
if (!in_array('delete', $blacklist, true)) {
if (
!in_array('delete', $blacklist, true) &&
$this->_crud()->action('delete')->enabled()
) {
$buttons[] = [
'title' => __d('crud', 'Delete'),
'url' => ['action' => 'delete'],
Expand Down
5 changes: 4 additions & 1 deletion src/Listener/ViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ protected function _getAllowedActions(): array
$blacklist = (array)$this->_action()->getConfig('scaffold.actions_blacklist');
$blacklist = array_combine($blacklist, $blacklist);
foreach ($this->_crud()->getConfig('actions') as $action => $config) {
if ($config['className'] === 'Crud.Lookup') {
if (
$config['className'] === 'Crud.Lookup' ||
!$this->_crud()->action($action)->enabled()
) {
$blacklist[$action] = $action;
}
}
Expand Down

0 comments on commit 0e993e5

Please sign in to comment.