Skip to content

Commit

Permalink
Issue #145: Replace front-facing bundle terminology with type.
Browse files Browse the repository at this point in the history
Fixes #145.
By @laryn.
  • Loading branch information
laryn committed Aug 29, 2022
1 parent 2ae3943 commit d8f65aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = Paragraphs Bundle Permissions
description = Add view / create / update / delete permissions for all paragraph bundles.
name = Paragraphs Type Permissions
description = Add view / create / update / delete permissions for all Paragraphs types.
backdrop = 1.x
type = module
package = Paragraphs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @file
* Add view / create / update / delete permissions for all paragraph bundles.
* Add view / create / update / delete permissions for all Paragraphs types.
*/

/**
Expand All @@ -12,18 +12,18 @@ function paragraphs_bundle_permissions_paragraphs_item_access($entity, $op, $acc
$permissions = &backdrop_static(__FUNCTION__, array());

if (!in_array($op, array('view', 'update', 'delete', 'create'), TRUE) || $entity === NULL) {
// If there is no bundle to check against, or the $op is not one of the
// If there is no type/bundle to check against, or the $op is not one of the
// supported ones, we return access ignore.
return PARAGRAPHS_ITEM_ACCESS_IGNORE;
}

$bundle = $entity->bundle;

// Set static cache id to use the bundle machine name.
// Set static cache id to use the type/bundle machine name.
$cid = $bundle;

// If we've already checked access for this bundle, user and op, return from
// cache.
// If we've already checked access for this type/bundle, user and op, return
// from cache.
if (isset($permissions[$account->uid][$cid][$op])) {
return $permissions[$account->uid][$cid][$op];
}
Expand All @@ -44,30 +44,30 @@ function paragraphs_bundle_permissions_paragraphs_item_access($entity, $op, $acc
function paragraphs_bundle_permissions_permission() {
$perms = array(
'bypass paragraphs bundle content access' => array(
'title' => t('Bypass paragraphs bundle content access control'),
'description' => t('Is able to administer content for all paragraph bundles'),
'title' => t('Bypass Paragraphs type content access control'),
'description' => t('Is able to administer content for all Paragraphs types'),
),
);

// Add permissions for each bundle.
// Add permissions for each type/bundle.
$bundles = paragraphs_bundle_load();
foreach ($bundles as $machine_name => $bundle) {
$perms += array(
'view paragraph content ' . $machine_name => array(
'title' => t('%type_name: View content', array('%type_name' => $bundle->name)),
'description' => t('Is able to view paragraphs content of bundle %type_name', array('%type_name' => $bundle->name)),
'description' => t('Is able to view Paragraphs content of type %type_name', array('%type_name' => $bundle->name)),
),
'create paragraph content ' . $machine_name => array(
'title' => t('%type_name: Create content', array('%type_name' => $bundle->name)),
'description' => t('Is able to create paragraphs content of bundle %type_name', array('%type_name' => $bundle->name)),
'description' => t('Is able to create Paragraphs content of type %type_name', array('%type_name' => $bundle->name)),
),
'update paragraph content ' . $machine_name => array(
'title' => t('%type_name: Edit content', array('%type_name' => $bundle->name)),
'description' => t('Is able to update paragraphs content of bundle %type_name', array('%type_name' => $bundle->name)),
'description' => t('Is able to update Paragraphs content of type %type_name', array('%type_name' => $bundle->name)),
),
'delete paragraph content ' . $machine_name => array(
'title' => t('%type_name: Delete content', array('%type_name' => $bundle->name)),
'description' => t('Is able to delete paragraphs content of bundle %type_name', array('%type_name' => $bundle->name)),
'description' => t('Is able to delete Paragraphs content of type %type_name', array('%type_name' => $bundle->name)),
),
);
}
Expand Down

0 comments on commit d8f65aa

Please sign in to comment.