function node_install

Same name in other branches
  1. 7.x modules/node/node.install \node_install()
  2. 9 core/modules/node/node.install \node_install()
  3. 10 core/modules/node/node.install \node_install()
  4. 11.x core/modules/node/node.install \node_install()

Implements hook_install().

File

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

Code

function node_install() {
    // 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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.