- First commit to issue fork.
- Merge request !83Issue #2879350 Add paragraph type setting to enable permission. β (Open) created by partdigital
- last update
12 months ago Composer require-dev failure - πΊπΈUnited States partdigital
I've rerolled the patch against 8.x-1.x and fixed the automated tests.
Changes can be found in this MR: https://git.drupalcode.org/project/paragraphs/-/merge_requests/83/diffs
I did make one change to however. If the permission setting isn't enabled for a paragraph then that paragraph simply isn't available to use at all. That would require us to turn on the setting for every single paragraph which kind of defeats the purpose of having the setting in the first place.
I've updated the access hooks so that Paragraphs are not restricted if the setting is disabled. This allows us to have some paragraphs that are controlled with permissions and others that aren't. On a site with 20+ paragraphs this helps a lot.
function paragraphs_type_permissions_paragraph_access(ParagraphInterface $entity, $operation, AccountInterface $account) { // If the permission does not exist then do not restrict access. $enable_permission = $entity->getParagraphType()->getThirdPartySetting('paragraphs_type_permissions', 'enable_permissions', FALSE); if (!$enable_permission) { return AccessResult::neutral(); } } function paragraphs_type_permissions_paragraph_create_access(AccountInterface $account = NULL, array $context = array(), $entity_bundle = NULL) { // If the permission does not exist then do not restrict access. $paragraph_type = \Drupal::entityTypeManager()->getStorage('paragraphs_type')->load($type); $enable_permission = $paragraph_type->getThirdPartySetting('paragraphs_type_permissions', 'enable_permissions', FALSE); if (!$enable_permission) { return AccessResult::neutral(); } }
- Status changed to Needs review
12 months ago 2:16pm 30 November 2023