Skip to content

Commit

Permalink
Merge pull request #234 from FriendsOfCake/141-blacklist-lookup
Browse files Browse the repository at this point in the history
feat: Blacklist Crud.LookupAction by default
  • Loading branch information
ADmad authored Feb 5, 2018
2 parents 216a945 + 2d0f06f commit df82b0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/_partials/pages/index/buttons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ Crud action classes are mapped but should not all be shown on the main UI.
$action = $this->Crud->action();
$action->config('scaffold.actions_blacklist', ['add', 'delete']);
By default, we blacklist the action which is mapped to ``Crud.LookupAction``.
As this action is meant to be used solely for autocompletion, it *cannot* be removed
from the ``scaffold.actions_blacklist`` list.

Action Groups
~~~~~~~~~~~~~

Expand Down
5 changes: 5 additions & 0 deletions src/Listener/ViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ protected function _getAllowedActions()

$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') {
$blacklist[$action] = $action;
}
}

return array_diff_key($allActions, $blacklist);
}
Expand Down

0 comments on commit df82b0f

Please sign in to comment.