Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. node.install

function node_install

Implements hook_install().

File

core/modules/node/node.install, line 123

Code

function node_install() : void {
    // Enable default permissions for system roles.
    // IMPORTANT: Modules SHOULD NOT automatically grant any user role access
    // permissions in hook_install().
    // However, the 'access content' permission is a very special case, since
    // there is hardly a point in installing the Node module without granting
    // these permissions. Doing so also allows tests to continue to operate as
    // expected without first having to manually grant these default permissions.
    if (\Drupal::moduleHandler()->moduleExists('user')) {
        user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
            'access content',
        ]);
        user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [
            'access content',
        ]);
    }
    // Populate the node access table.
    Database::getConnection()->insert('node_access')
        ->fields([
        'nid' => 0,
        'gid' => 0,
        'realm' => 'all',
        'grant_view' => 1,
        'grant_update' => 0,
        'grant_delete' => 0,
    ])
        ->execute();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal