- 🇩🇪Germany guido_s Cologne
I think the publication_date module solved this in a good way using permission callbacks in its permissions.yml and then extending the NodePermissions class.
permission_callbacks: - \Drupal\publication_date\PublicationDateNodePermissions::nodeTypePermissions
use Drupal\node\Entity\NodeType; use Drupal\node\NodePermissions; /** * Permissions to "Published On" field. */ class PublicationDateNodePermissions extends NodePermissions { /** * Returns an array of node type permissions. * * @return array * The node type permissions. * @see \Drupal\user\PermissionHandlerInterface::getPermissions() */ protected function buildPermissions(NodeType $type): array { $type_id = $type->id(); $type_params = ['%type_name' => $type->label()]; return [ "set $type_id published on date" => [ 'title' => $this->t('Modify %type_name "Published On" date.', $type_params), 'description' => $this->t('Change the "Published On" date for this content type.'), ], ]; } }
Something like this could be used here too.
- Status changed to Needs review
9 months ago 4:52pm 7 February 2024 - 🇩🇪Germany guido_s Cologne
I added it like that and opened a merge request.
Please test if everything works as expected. - 🇩🇪Germany guido_s Cologne
We need to check if the core version requirements in the info file need to be changed for this. I currently don't know if the NodePermissions class existed in Drupal 8 and only the bundle permissions trait was added later or something like that.