Issue #3350210: Enable the Manage Permissions tab
Merge request reports
Activity
93 94 94 95 return $permissions[$account->id()][$type][$op]; 95 96 } 97 98 /** 99 * Implements hook_entity_type_alter(). 100 */ 101 function paragraphs_type_permissions_entity_type_alter(array &$entity_types) { 102 $providers = $entity_types['paragraphs_type']->getRouteProviderClasses() ?: []; 103 if (empty($providers['permissions'])) { 104 $providers['permissions'] = EntityPermissionsRouteProvider::class; 105 $entity_types['paragraphs_type']->setHandlerClass('route_provider', $providers); 106 if (!$entity_types['paragraphs_type']->hasLinkTemplate('entity-permissions-form')) { 107 $entity_types['paragraphs_type']->setLinkTemplate('entity-permissions-form', '/admin/structure/paragraphs_type/{paragraphs_type}/permissions'); 107 $entity_types['paragraphs_type']->setLinkTemplate('entity-permissions-form', '/admin/structure/paragraphs_type/{paragraphs_type}/permissions'); 107 $entity_types['paragraphs_type']->setLinkTemplate( 108 'entity-permissions-form', 109 '/admin/structure/paragraphs_type/{paragraphs_type}/permissions' 110 ); Not everyone cares about long lines as much as I do, but it is in the coding standards: https://www.drupal.org/docs/develop/standards/php/php-coding-standards#linelength
55 55 $type_id = $type->id(); 56 56 $type_params = array('%type_name' => $type->label()); 57 57 58 return array( 59 'view paragraph content ' .$type_id => array( 58 $permissions = [ 59 'view paragraph content ' .$type_id => [ - Comment on lines +58 to +59
Personally, I prefer to interpolate, as you did on Line 80:
"view paragraph content $type_id"
.It is debatable whether to fix coding standards (like changing from long array syntax to short) as part of this issue. But I will let the maintainers decide that. If we are going to clean up these lines, let's insert the missing space.
changed this line in version 2 of the diff
39 39 $perms += $this->buildPermissions($type); 40 40 } 41 41 42 42 return $perms; - Comment on lines 34 to 42
It would be simpler to use
BundlePermissionHandlerTrait
here, as in the change record. Then you would not need to make any changes to thebuildPermissions()
method. I am a little annoyed that GitLab shows Lines 39-42, even though it knows that I am commenting on 34-42.
public function paragraphTypePermissions() { $perms = array(); // Generate paragraph permissions for all Paragraphs types. foreach (ParagraphsType::loadMultiple() as $type) { $perms += $this->buildPermissions($type); } return $perms; }
changed this line in version 2 of the diff
added 1 commit