Created on 4 March 2022, over 2 years ago
Updated 30 April 2023, about 1 year ago

Hello,
I would like to create a custom module that uses content access.
I have a boolean within a content type and depending on its values, I would like to adjust the access rights.

I sucessfully generate the code within hooks (hook_ENTITY_TYPE_update() and hook_ENTITY_TYPE_insert()) to manage the content access settings.
with content_access_save_per_node_settings($node, $settings);

But the node access configuration is not applied to the node as I have an issue to port the below code to my custom module.

    // Apply new settings.
    $grants = $this->entityTypeManager->getAccessControlHandler('node')->acquireGrants($node);
    $this->grantStorage->write($node, $grants);

I found https://api.drupal.org/api/drupal/core%21modules%21node%21src%21NodeAcce... which says that it is deprecated and \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants() should be used instead.
Thanks for your help.

πŸ’¬ Support request
Status

Closed: outdated

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡΄Norway gisle Norway

    This should go into the the most recent branch.

  • Status changed to Closed: outdated about 1 year ago
  • πŸ‡³πŸ‡΄Norway gisle Norway

    There is no patch or merge request, and it is unclear what the support request is.
    Comment #3 indicate the OP consider it "Fixed".
    I am closing this. Feel free to open if you can be more specific about what this is about.

Production build 0.69.0 2024