Problem/Motivation
ParagraphsBrowserForm does not check access correctly. Users will still be presented types that they are forbidden to create.
Steps to reproduce
Set up Paragraphs browser for a paragraphs field. Implement a custom entity create access hook for Paragraphs that will deny creation access to a bundle that is allowed to be added to the field, such as:
function hook_paragraph_create_access(\Drupal\Core\Session\AccountInterface $account, array $context, string $entity_bundle) {
return $entity_bundle === 'mybundle'
? \Drupal\Core\Access\AccessResult::forbidden()
: \Drupal\Core\Access\AccessResult::neutral();
}
Then use the paragraphs browser widget. On the modal form, you will still see 'mybundle' as an option to add. You will get an error if you try to actually click it to add the forbidden type - so access is still denied, it's just not good UX.
Proposed resolution
Instead of a conditional that hardcodes checking certain permissions that are specifically from the paragraphs_type_permissions submodule of Paragraphs, the standard Drupal entity access handler should be used.
Remaining tasks
MR & review.
User interface changes
Users will no longer be able to see.
API changes
Data model changes
Issue fork paragraphs_browser-3374267
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
bvoynickOpened MR 6 with proposed resolution.
Comment #4
damienmckennaComment #6
bvoynickThanks for the review! Rebased & merged.